{$CLEO .cs}
{$USE CLEO+}
0000: nop



:Restart
wait 0
0570: $1000 = create_asset_radar_marker_with_icon 19 at 2475.4124 -1750.3705 13.5469  //// Delivery job radar icon
03BC: 0@ = create_sphere_at 2475.4124 -1750.3705 13.5469 radius 2.0  ///// START CLEO MOD LOC

$ONMISSION = 0

$Actor1Dialog01 = 0 // If (1), the $Actor1 will have a short dialog and won't help.
$Actor1Dialog02 = 0 // If (1), the $Actor1 will have a short dialog and won't help.
$Actor1Dialog03 = 0 // If (1), the $Actor1 will have a short dialog and won't help.
$Actor1Dialog04 = 0 // If (1), the $Actor1 will have long dialog and will help.

///////////--------
$Actor1DidTask = 0  /// Is set to 1 after loading boxes into truck
$Actor1FollowPlayer = 0
$Actor1InCarWithPlayer = 0
$SashaDroppedOff = 0
///////****************************<<<<

$Actor1IsDeliveringBox = -1
$MakeSashaDeliverBox1 = -1

$SashaDialogMENU_Open = 0
$CloseDialogMENUNormal = 1

$EnableSashaFollowSystem = 0

$TruckDoorsOpen = 0
$BOTV_SPHERE_VAR = 0 

$FightWithSashaHusband = 0    ////       CHANCE OF FIGHTING WITH SASHA'S HUSBAND AT THE DROP OFF IN THE END

$StopCloserWarn = 0

$ChooseActor1RandomTalkToLoadBox = -1  // VAR to SET ON a random dialog while $Actor1 puts a box into the $Truck
$ChooseActor1RandomTalkToLoadBox_RANDOMRANGE = -1  //// VAR to choose a random dialog while $Actor1 puts a box into the $Truck

$TrunkID = -1

////////////////
Var 21@: int
Var 22@: int
Var 23@: int
Var 24@: int
///////////////
21@ = 15.0
22@ = 15.0
23@ = 15.0
24@ = 15.0



Var $SashaDeliverTimerStart: int
Var $SashaDeliverTimerStarted: int
$SashaDeliverTimerStarted = 1  /// TIMERA ORDER $Actor1 GOTO POINT
$SashaDeliverTimerStart = -1


///////////////////////////////////
var $LocToResetAfterSashaDeliverBox: int
var $Delivered0: int
var $Delivered1: int
var $Delivered2: int
var $Delivered3: int
var $Delivered4: int
var $Delivered5: int
var $Delivered6: int
var $Delivered7: int
var $Delivered8: int
var $Delivered9: int
var $Delivered10: int
////////////////////////////
$LocToResetAfterSashaDeliverBox = -1

//////////////////////////
var $HouseForSashaToDeliver_X: float
var $HouseForSashaToDeliver_Y: float
var $HouseForSashaToDeliver_Z: float
var 4@: float
var 5@: float
var 6@: float
var 7@: float
var 8@: float
var 9@: float

var $Actor1DeliverRadiusDist1: float 
var $Actor1DeliverRadiusDist2: float
//////////////////////////////////
$HouseForSashaToDeliver_X = -1
$HouseForSashaToDeliver_Y = -1

$Actor1DeliverRadiusDist1 = 1000.0
$Actor1DeliverRadiusDist2 = 1000.0
 
 //////////////////
var $Actor1: object
var $CurrentBox : object
var $DeliveryPayout: int
///////////
$Actor1 = -1
$CurrentBox = -1

$DeliveryPayout = 300  //// VALUE TO MULTIPLY PER DELIVERY LOCATION

// DROPPED BOXES MEMORY SLOTS
var $DropB0: object
var $DropB1: object
var $DropB2: object
var $DropB3: object
var $DropB4: object
var $DropB5: object
var $DropB6: object
var $DropB7: object
var $DropB8: object
var $DropB9: object
var $DropB10: object
//////////////////////////
// DROPPED BOXES MEMORY SLOTS
$DropB0 = -1
$DropB1 = -1
$DropB2 = -1
$DropB3 = -1
$DropB4 = -1
$DropB5 = -1
$DropB6 = -1
$DropB7 = -1
$DropB8 = -1
$DropB9 = -1
$DropB10 = -1
//////////////////////

// Boxes object 
var $ObjDropB0: object
var $ObjDropB1: object
var $ObjDropB2: object
var $ObjDropB3: object
var $ObjDropB4: object
var $ObjDropB5: object
var $ObjDropB6: object
var $ObjDropB7: object
var $ObjDropB8: object
var $ObjDropB9: object
var $ObjDropB10: object

///////////////////
var $SpawnedBoxes: int  
///////////////////

$SpawnedBoxes = 0
//////////////
var $BoxToSpawn: object
//////////////
$BoxToSpawn = -1 /// Holding box at moment


$BDV_MENU_OPEN = 0

$Truck = -1
$BackOfTheVanSphereCreatedVariable = 0
$BDV_SphereOn = 0

$VehLightsOn = 0
$VehEngineOn = 1
$TruckLocked = 0

$HoldingObjectAtMoment = -1 // Bool if i'm holding an object

$PlayCarryingBoxAnim = 0
$AnimStatus = 0

$DroppingBox = 0  ///Var when player is dropping a box on runtime

//////////////////// 
$Delivered0 = 0
$Delivered1 = 0
$Delivered2 = 0
$Delivered3 = 0
$Delivered4 = 0
$Delivered5 = 0
$Delivered6 = 0
$Delivered7 = 0
$Delivered8 = 0
$Delivered9 = 0
$Delivered10 = 0

////////////////////////// We must declare these variables first
Var $MaxDeliveriesToMake: int /////$MaxDeliveriesToMake = 2
var $TempChosenDeliveries: int
var $BoxesDelivered: int
var $LoadedBoxesIntoTruck : int
var $LastDeliveredBox: object 
var $Delivered: int
var $ChosenDeliveryQTY: int

///////////////////////
$LastDeliveredBox = -1 ///Object to check before spawning a new box from truck or whatever. If i delivered a box, this prevent multiple objects to remain in the game forever.

//////////////////////////
$LoadedBoxesIntoTruck = 0  //// How many boxes are already in truck    
///////////***********
$MaxDeliveriesToMake = -1   ////// How many deliveries to make???   ///////////////*******************<<<<<<<<<<<<<<<<<<<<<<<<
//////*******************
$TempChosenDeliveries = 0  /// Used to take $MaxDeliveriesToMake max ammount of deliveries to make and use as the limit of locations.

$BoxesDelivered = 0
$Delivered = 0  ////Internal check code that will increase the more deliveries you do. $MaxDeliveriesToMake is the max ammount.
$ChosenDeliveryQTY = -1 ///// How many deliveries i choose to do?

$TruckBoxMessage = 0
////////////////////////////////
var $H0: int
var $H1: int
var $H2: int
var $H3: int
var $H4: int
var $H5: int
var $H6: int
var $H7: int
var $H8: int
var $H9: int
var $H10: int

var $HouseFrontMarker0: marker
var $HouseFrontMarker1: marker
var $HouseFrontMarker2: marker
var $HouseFrontMarker3: marker
var $HouseFrontMarker4: marker
var $HouseFrontMarker5: marker
var $HouseFrontMarker6: marker
var $HouseFrontMarker7: marker
var $HouseFrontMarker8: marker
var $HouseFrontMarker9: marker
var $HouseFrontMarker10: marker

var $Sasha_DeliverLOC_Sphere: int
var $Sasha_DeliverLOC_Marker: marker
//////////////////////////////

$Sasha_DeliverLOC_Sphere = -1
$Sasha_DeliverLOC_Marker = -1

//////////////////////////////////////////////////
var $H0_X: float
var $H0_Y: float

var $H1_X: float
var $H1_Y: float

var $H2_X: float
var $H2_Y: float

var $H3_X: float
var $H3_Y: float

var $H4_X: float
var $H4_Y: float

var $H5_X: float
var $H5_Y: float

var $H6_X: float
var $H6_Y: float

var $H7_X: float
var $H7_Y: float

var $H8_X: float
var $H8_Y: float

var $H9_X: float
var $H9_Y: float

var $H10_X: float
var $H10_Y: float

var $H0_Z: float
var $H1_Z: float
var $H2_Z: float
var $H3_Z: float
var $H4_Z: float
var $H5_Z: float
var $H6_Z: float
var $H7_Z: float
var $H8_Z: float
var $H9_Z: float
var $H10_Z: float
/////////////////////////////////
Var $TruckBox0: object
Var $TruckBox1: object
Var $TruckBox2: object
Var $TruckBox3: object
Var $TruckBox4: object
Var $TruckBox5: object
Var $TruckBox6: object
Var $TruckBox7: object
Var $TruckBox8: object
Var $TruckBox9: object
Var $TruckBox10: object

Var $Truck_VisualBox: object    ////////////  TRUCK VISUAL BOX TO SPAWN INDEPENDENT BOX INSIDE TRUCK
////////////
$TruckBox0 = -1
$TruckBox1 = -1
$TruckBox2 = -1
$TruckBox3 = -1
$TruckBox4 = -1
$TruckBox5 = -1
$TruckBox6 = -1
$TruckBox7 = -1
$TruckBox8 = -1
$TruckBox9 = -1
$TruckBox10 = -1

//////////////////////////////////////OBJECTS IDS
$Box1 = 1279
$Box2 = 1579 
$Box3 = 1580
$Box4 = 3033

$NegativeCheck = 0

Player.CanMove($PLAYER_CHAR) = true 



////////////////////////////////////////////////////////////////////////////////////////BASE MISSION SETUP //////////////--------------
:Setup_Mission
wait 0 

 
0247: request_model #BOXVILLE 
0247: request_model 413 // PONY
0247: request_model 414 // MULE
0247: request_model #PEREN //Perennial
///////////////////////////// objects
0247: request_model 1279 /// White package
0247: request_model 1579 /// blue package
0247: request_model 1580 /// Wooden box  1
0247: request_model 3033 /// Red package


/////////////////////////////////
0247: request_model #vbfycrp  /// NPC
0247: request_model #wmygol2 /// Sasha's boyfriend
04ED: load_animation "CARRY"
038B: load_requested_models // <--- THIS TELLS THE GAME TO LOAD THEM





:Check_Start
wait 0
gosub @MissionFailedCheck0  

if and
    00EC: actor $PLAYER_ACTOR sphere 0 near_point 2475.4124 -1750.3705 radius 2.0 2.0
    not $ONMISSION == 1
then
    if
        0AB0: key_pressed 70
    then
        03BD: destroy_sphere 0@
        $ONMISSION = 1
        015F: set_camera_position 2462.1533 -1729.0382 18.4030 rotation 0.0 0.0 205.2478
        0160: set_camera_point_at 2466.0525 -1741.5500 13.4030 switchstyle 2
        03BD: destroy_sphere 0@
        0164: disable_marker $1000
        wait 400
        jump @ChooseAVehicleMENU
    else
        0AD1: show_formatted_text_highpriority "~g~Press ~y~F ~g~to start delivery job!" time 1000
    end
end

jump @Check_Start

///////////////////////////////********************************************************************** ////>>>>>>>>>>>>>>>>>>>>>>> GAME START
:StartMission1  
wait 0

/////////////////   NPC HELP PLAYER TO PUT BOXES IN THE TRUCK
jump @NPCLookForBox ///////////**************  MAKE NPC PICKUP A BOX SECTION BEFORE START


:StartMission2 
wait 0 
/////////////////CHOSE RANDOM HOUSE
jump @HousesCurrentAvaiability

//////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<*/************

//////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<*/************          B E F O R E   D E F I N I T I V E  L O O P 
:StartMission3
0AD1: show_formatted_text_highpriority "~g~ Drive to the locations and deliver the boxes!" time 5000  



//////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<*/************  //////////////////////////MISSION START////////<<<<<<<<<<<<<<<<<<<<<<<<<*/************
:HousesCoordinates
wait 0 

if
    $BDV_MENU_OPEN == 1
then
    wait 0
    jump @HousesCoordinates
end

////////////////
if
  00DB: actor $PLAYER_ACTOR in_car $Truck
then
  02AC: set_car $Truck immunities BP 0 FP 0 EP 0 CP 0 MP 0
end
///////////////////////////////////////////////////////////////////

///////////////////////////////////////   UNIVERSAL 'G' KEY LOGIC ( DROP)
gosub @PressGToDropBox
//////////////////////////////////  PRESS G (PICKUP)
gosub @PressGToPickupBox
/////////////////////////////////
gosub @CarMechanisms   /// Car engine and lights
gosub @MissionFailedCheck1  // Check car exploded or player dead
gosub @CanceledMission ///////////// IF I PRESS *P TO CANCEL MISSION
/////////////////////////////////////////////////////---------------------
/////////////////////////////////////////////////// IF PRESS F, OPEN BACK OF THE VAN MENU
gosub @OpenBackOfTheVanMenu

///////////////////////////////////// SASHA RUNTIME ORDERS MENU
gosub @Actor1FollowSystem


if  ///////////////////////// CHECK CARRYING BOX ANIM
 not $AlreadyPlaying_CarryingBox == 1
then 
   gosub @CJCarryBoxAnimCheck
end       
///////////////////////////



/////////////////// OPEN SASHA DIALOG MENU IF I PRESS ''M''
if 
  0AB0: key_pressed 77 
 then
  if and
    00F2: actor $PLAYER_ACTOR near_actor $Actor1 radius 15.0 15.0 sphere 0
    $SashaDialogMENU_Open == 0
    $Actor1DidTask == 1
    not $SashaDroppedOff == 1
   then
     gosub @SashaDialogMENU
     
     // FIX: Catch the jump AFTER the gosub is cleared from memory!
     if $MakeSashaDeliverBox1 == 1
     then
         jump @ClosestDelLoc
     end
  end
end




///////////////////////////////  IF SASHA IS CLOSE TO A DELIVERY LOCATION ON FOOT OR IN CAR, GET OUT, PICK UP A BOX AND DELIVER
if and
  $Actor1DidTask == 1
  $MakeSashaDeliverBox1 == 1   
  $SashaDroppedOff == 0       
then  
    jump @MakeSashaDeliverBox1
end
/////////////////////////////////////////////////








////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////Check if all the deliveries were made
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0
04C4: store_coords_to 12@ 13@ 14@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
0509: 15@ = distance_between_XY 9@ 10@ and_XY 12@ 13@

if
    $BoxesDelivered == $MaxDeliveriesToMake
then
    if and
     15@ < 50.0
     $SashaDroppedOff == 0
    then
        $SashaDeliveredTheBox = 1
        $Actor1FollowPlayer = 1
        $EnableSashaFollowSystem = 1
        wait 100
        jump @TakeSashaBack
    else
      if and
        $SashaDroppedOff == 1
        $BoxesDelivered == $MaxDeliveriesToMake
       then  
         jump @Finish
      end 
   end 
end


///////////////IF PLAYER IS ALONE

if
    $BoxesDelivered == $MaxDeliveriesToMake
then
    if 
     15@ > 50.0
    then
        $SashaDeliveredTheBox = 1
        $Actor1FollowPlayer = 1
        $EnableSashaFollowSystem = 1
        wait 100
        jump @Finish
   end
end

////////////////////////////////////////////////////////////////////////////////////////////////////



if
    $PlayCarryingBoxAnim == 1
then
     0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 500
end


if
    $PlayCarryingBoxAnim == 0
then
     0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
end












/////////////////////////
gosub @CheckDeliveryLocations /// Has player delivered any boxes?


  

/////////////////////////////////////////////----------------------




jump @HousesCoordinates   /////////Loop main mission


:Finish
wait 0
03BD: destroy_sphere $FinishDeliveryWithSasha_Sphere
0164: disable_marker $FinishDeliveryWithSashaSphere_Marker

$PlayCarryingBoxAnim = 0
0AD1: show_formatted_text_highpriority "~g~ Thank you, my boy! All the boxes were delivered!" time 5000
wait 3000
0AD1: show_formatted_text_highpriority "~g~ MISSION PASSED!" time 5000
wait 200
$DeliveryPayout = $MaxDeliveriesToMake
$DeliveryPayout *= 300
0AD1: show_formatted_text_highpriority "~g~Payout:~w~ $%d" time 3000 $DeliveryPayout
wait 200
02EB: restore_camera_with_jumpcut

01B4: set_player $PLAYER_CHAR can_move 1

jump @MISSIONCLEANUP
/////////////////////////////////////////////////////////////






////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
////////////////////////////////////////////////////////////////////////////////G O  S U B S //////////////////////////<<<<<<<<<<<<<<<>>>>>>>>>>>BOX TO DELIVER MENU   >>>>>>>>>>>>>>>>>>>>>>>>          
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////BACK OF THE VAN MENU ///--------OPEN MENU TO CHOOSE A BOX TO DELIVER///

:BackOfTheVanMENU /////////
wait 0 
0ACA: show_text_box "~g~Press ~b~Backspace to cancel and close menu."
0519: set_car $Truck locked 1
$BDV_MENU_OPEN = 1
03BF: set_player $PLAYER_CHAR ignored_by_everyone 1
Player.CanMove($PLAYER_CHAR) = False

//////////////////////////////////////////////////////////////////////////////////CREATE THE BACK OF THE VAN MENU TO CHOOSE A BOX TO DELIVER
08D4: $BackOfTheVanMENU = create_panel_with_title 'DUMMY' position 29.0 200.0 width 150.0 columns 1 interactive 1 background 1 alignment 0
08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B0' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
///Activate rows
gosub @ChangeBDVPanelState
08D9: set_panel $BackOfTheVanMENU row 0 enable 0
08D9: set_panel $BackOfTheVanMENU row 1 enable 1
08D9: set_panel $BackOfTheVanMENU row 2 enable 1
///////////////////////////////////////////////////-------------------------

$SelectedBoxRow = 0


/////////////////////////////////////////////////
08A6: set_car $Truck door $TrunkID rotation_to 1.0

$TruckDoorsOpen = 1

///////CLOSE MENU
:BackOfTheVanMENU2
wait 0
08D8: $SelectedBoxRow = panel $BackOfTheVanMENU selected_row


/////////////////////////////////


if
0AB0: key_pressed 8  ///backspace
then
    jump @CloseBackOfTheVanPanel
end    
/////////////////////////////

// 2. /////////////////////////////////// Check for Selection LOAD A BOX INTO VEHICLE
 //////////////  IT'S IMPORTANT TO PUT THE ACTIONS UNDER KEYPRESSES AND NOT KEY PRESSES FOR EACH OPTION THAT MIGHT EXISTS!////////////----
 
 //////////////////////////////////////////////////////// L O A D  B O X  I N  T R U C K 
if or    
    0AB0: key_pressed 13 // Enter
    0AB0: key_pressed 160 // Shift
  then
    // --- OPTION: LOAD BOX INTO TRUCK (Row 1) ---
    if
      $SelectedBoxRow == 1
    then
        if 
         $LoadedBoxesIntoTruck == 10
        then
            0AD1: show_formatted_text_highpriority "~r~ Truck is already full of boxes!" time 1500
            jump @CloseBackOfTheVanPanel 
      end

///////// If i'm holding a box and can put into the truck
if
 $SelectedBoxRow == 1
  then
    if and
     not $HoldingObjectAtMoment == -1
     $LoadedBoxesIntoTruck < 10    
   then
     0407: store_coords_to 9@ 10@ 11@ from_car $Truck with_offset 0.0 -2.5 0.3
     0682: detach_object $BoxToSpawn 0.0 0.0 0.0 collision_detection 0  //// DO IT TO AVOID CRASHING
     0108: destroy_object $BoxToSpawn 
     wait 50
     $BoxToSpawn = -1
     $HoldingObjectAtMoment = -1
     wait 50
     $LoadedBoxesIntoTruck += 1
     gosub @UpdateTruckVisualBoxes 
     

     
     $NegativeCheck = 0
     0AD1: show_formatted_text_highpriority "~g~ You put a box in the truck." time 1500
     0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
     $PlayCarryingBoxAnim = 0
     jump @CloseBackOfTheVanPanel 
 end
///////// If i'm empty handed and try to ''load a box into the truck''        
if
 $SelectedBoxRow == 1
  then
    if and
     $HoldingObjectAtMoment == -1
     $LoadedBoxesIntoTruck < 10    
     $PlayCarryingBoxAnim = 0
   then        
      0AD1: show_formatted_text_highpriority "~g~ You're not holding an object." time 1500 
      jump @CloseBackOfTheVanPanel          
          end
       end
    end
 end
end

     
////////////////////////////////////////////////// T A K E  B O X  F R O M  T R U C K 
////////////////////////////// If i'm holding a box already.
if or    
    0AB0: key_pressed 13 // Enter
    0AB0: key_pressed 160 // Shift
then    
if
 $SelectedBoxRow == 2
 then
  if
   $LoadedBoxesIntoTruck > 0    
  then 
    if
     $HoldingObjectAtMoment > -1
   then
     0AD1: show_formatted_text_highpriority "~r~ You're already holding a box. You can't take another one at same time!" time 1500
     jump @CloseBackOfTheVanPanel 
end
  ///////////////////////////////If truck has boxes and i'm not holding any boxes.
  if
   $SelectedBoxRow == 2
 then
  if
   $LoadedBoxesIntoTruck > 0    ///Truck has boxes
  then 
    if
     $HoldingObjectAtMoment == -1  // I'm not holding any boxes
   then   
     0AD1: show_formatted_text_highpriority "~g~ Box taken out of the truck." time 1300
     gosub @UpdateTruckVisualBoxes 
     jump @PickupBox1
 end
 
 //////////////////////////// If truck has no boxes inside.
 
 if
   $SelectedBoxRow == 2
 then
  if
   $LoadedBoxesIntoTruck == 0    
  then 
    0AD1: show_formatted_text_highpriority "~r~ Truck is empty! You need to take more boxes from the back of the store or the ones you might've left on ground!" time 1500
    0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
    jump @CloseBackOfTheVanPanel 
                 end
              end
           end
        end
     end
  end
end                         
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

jump @BackOfTheVanMENU2
return


//////////////////////////////////////////////////////PICK UP A BOX FROM VAN MENU       *******************************************<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>
:PickupBox1   ////<<<<<<<<<<<<<<BOX 1
wait 0
04C4: store_coords_to 9@ 10@ 11@  from_actor $PLAYER_ACTOR with_offset 0.0 -4.5 0.0
0107: $BoxToSpawn = create_object 1580 at 9@ 10@ 11@ 
069B: attach_object $BoxToSpawn to_actor $PLAYER_ACTOR with_offset 0.0 0.60 0.30 rotation 0.0 0.0 0.0  
$HoldingObjectAtMoment = 0
$PlayCarryingBoxAnim = 1
$LoadedBoxesIntoTruck -= 1
gosub @UpdateTruckVisualBoxes

$NegativeCheck = 0
0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time -1
wait 50
jump @CloseBackOfTheVanPanel 



/////////////////////////////////////////////////////////////////////////////
:PickupBox2  ////<<<<<<<<<<<<<< BOX 2 
wait 0
04C4: store_coords_to 9@ 10@ 11@  from_actor $PLAYER_ACTOR with_offset 0.0 -4.5 0.0
0107: $BoxToSpawn = create_object 1279 at 9@ 10@ 11@ 
069B: attach_object $BoxToSpawn to_actor $PLAYER_ACTOR with_offset 0.0 0.60 0.30 rotation 0.0 0.0 0.0
$HoldingObjectAtMoment = 1
$PlayCarryingBoxAnim = 1
$LoadedBoxesIntoTruck -= 1
gosub @UpdateTruckVisualBoxes 
$NegativeCheck = 0
0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time -1
wait 50
jump @CloseBackOfTheVanPanel 




////////////////////////////////////////////////////CLOSE BAKC OF THE VAN MENU
:CloseBackOfTheVanPanel
wait 0
08DA: remove_panel $BackOfTheVanMENU   
$BDV_MENU_OPEN = 0
08A6: set_car $Truck door $TrunkID rotation_to 0.0
$TruckDoorsOpen = 0
03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
Player.CanMove($PLAYER_CHAR) = True
0519: set_car $Truck locked 0
return
/////////////////////////////////////////////////////////////////////////////////////////////////////////






//////////////////////////////////////////////////////////////////////////////////////////////////////////-------------------  C H O O S E  D E L I V E R Y  V E H I C L E

//////////////////////////////////////////////////Choose a vehicle MENU ///--------------------------------------------
:ChooseAVehicleMENU /////////
wait 0 
0ACA: show_text_box "~g~Press ~b~Backspace to cancel and close menu."
Player.CanMove($PLAYER_CHAR) = False

//////////////////////////////////////////////////////////////////////////////////
08D4: $ChooseAVehicleMENU = create_panel_with_title '1' position 29.0 180.0 width 90.0 columns 3 interactive 1 background 1 alignment 0
08DB: set_panel $ChooseAVehicleMENU column 0 header 'DUMMY' data '2' '3' '4' '5' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
///Activate rows
08D9: set_panel $ChooseAVehicleMENU row 0 enable 1
08D9: set_panel $ChooseAVehicleMENU row 1 enable 1
08D9: set_panel $ChooseAVehicleMENU row 2 enable 1
08D9: set_panel $ChooseAVehicleMENU row 3 enable 1
/////////////////////////////////////////////////

$SelectedCarRow = 0

03BF: set_player $PLAYER_CHAR ignored_by_everyone 1

:ChooseAVehicleMENU2 //////////////////////////////
wait 0

08D8: $SelectedCarRow = panel $ChooseAVehicleMENU selected_row

///////CLOSE MENU
wait 0
if
0AB0: key_pressed 8  ///backspace
then
   jump @GiveUpChoosingVehicle
end
//////////////////////////////

 ///413 // PONY
///414// MULE
///BOXVILLE 

     
// 2. /////////////////////////////////// I
if
  $SelectedCarRow == 0 
then
    00A5: $Truck = create_car 413 at 2471.4260 -1754.9073 13.5469 
    0175: set_car $Truck z_angle_to -90.0
    02AC: set_car $Truck immunities BP 1 FP 1 EP 1 CP 1 MP 1
    $TrunkID = 4
    jump @CloseChooseAVehiclePanel      
end
if 
  $SelectedCarRow == 1 
then
    00A5: $Truck = create_car 414 at 2471.4260 -1754.9073 13.5469 
    0175: set_car $Truck z_angle_to -90.0
    02AC: set_car $Truck immunities BP 1 FP 1 EP 1 CP 1 MP 1
    $TrunkID = 1
    jump @CloseChooseAVehiclePanel       
end
if 
  $SelectedCarRow == 2
then
    00A5: $Truck = create_car #BOXVILLE at 2471.4260 -1754.9073 13.5469 
    0175: set_car $Truck z_angle_to -90.0 
    02AC: set_car $Truck immunities BP 1 FP 1 EP 1 CP 1 MP 1
    $TrunkID = 4
    jump @CloseChooseAVehiclePanel               
end

if 
  $SelectedCarRow == 3
then
    00A5: $Truck = create_car #PEREN at 2471.4260 -1754.9073 13.5469 
    0175: set_car $Truck z_angle_to -90.0 
    02AC: set_car $Truck immunities BP 1 FP 1 EP 1 CP 1 MP 1
    $TrunkID = 1
    jump @CloseChooseAVehiclePanel               
end

jump @ChooseAVehicleMENU2


////////////////////////////////////////////////////CLOSE CHOOSE VEHICLE MENU
:CloseChooseAVehiclePanel
wait 0

08DA: remove_panel $ChooseAVehicleMENU   
wait 300
jump @HowManyDeliveriesMENU

////////////////
:GiveUpChoosingVehicle
wait 0

08DA: remove_panel $ChooseAVehicleMENU   
03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
02EB: restore_camera_with_jumpcut
0826: enable_hud 1
0581: enable_radar 1
01B4: set_player $PLAYER_CHAR can_move 1
Player.CanMove($PLAYER_CHAR) = True 
jump @Restart

////////////////////////////////////////////////////************************--------------------------------------------------------
////////////////////////////////////////////////////************************--------------------------------------------------------





//////////////////////////////////////////////////////////////////////////////////////////////////////////-------------------  C H O O S E  H O W  M A N Y  D E L I V E R I E S  M E N U

//////////////////////////////////////////////////Choose how many deliveries MENU ///--------------------------------------------
wait 300
:HowManyDeliveriesMENU /////////
wait 0 
 0ACA: show_text_box "~g~Press ~b~Backspace to cancel and close menu."
Player.CanMove($PLAYER_CHAR) = False

//////////////////////////////////////////////////////////////////////////////////
08D4: $HowManyDeliveriesMENU = create_panel_with_title 'HD' position 29.0 180.0 width 90.0 columns 3 interactive 1 background 1 alignment 0
08DB: set_panel $HowManyDeliveriesMENU column 0 header 'DUMMY' data 'HD0' 'HD1' 'HD2' 'HD3' 'HD4' 'HD5' 'HD6' 'HD7' 'HD8' 'HD9' 'HD10' 'DUMMY'
///Activate rows
08D9: set_panel $HowManyDeliveriesMENU row 0 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 1 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 2 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 3 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 4 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 5 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 6 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 7 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 8 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 9 enable 1
08D9: set_panel $HowManyDeliveriesMENU row 10 enable 1

/////////////////////////////////////////////////

$SelectedDeliveriesQTY = 0

03BF: set_player $PLAYER_CHAR ignored_by_everyone 1

:HowManyDeliveriesMENU2 //////////////////////////////
wait 0

08D8: $SelectedDeliveriesQTY = panel $HowManyDeliveriesMENU selected_row

///////CLOSE MENU
wait 0
if
0AB0: key_pressed 8  ///backspace
then
    jump @DeleteVeh_And_CloseMENU
end
//////////////////////////////

     
// 2. /////////////////////////////////// I
if or    
    0AB0: key_pressed 13 // Enter
    0AB0: key_pressed 160 // Shift
  then

if
  $SelectedDeliveriesQTY == 1 
then
   $MaxDeliveriesToMake = 1 
   $Actor1Dialog01 = 1  
   $ChosenDeliveryQTY = 1
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 2
then
   $MaxDeliveriesToMake = 2  
   $Actor1Dialog01 = 1  
   $ChosenDeliveryQTY = 2
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 3 
then
   $MaxDeliveriesToMake = 3   
   $Actor1Dialog01 = 1  
   $ChosenDeliveryQTY = 3
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 4
then
   $MaxDeliveriesToMake = 4  
   $ChosenDeliveryQTY = 4 
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 5
then
   $MaxDeliveriesToMake = 5   
   $ChosenDeliveryQTY = 5
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 6
then
   $MaxDeliveriesToMake = 6   
   $ChosenDeliveryQTY = 6
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 7
then
   $MaxDeliveriesToMake = 7  
   $ChosenDeliveryQTY = 7 
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 8
then
   $MaxDeliveriesToMake = 8   
   $ChosenDeliveryQTY = 8
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 9
then
   $MaxDeliveriesToMake = 9   
   $ChosenDeliveryQTY = 9
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
end

if
  $SelectedDeliveriesQTY == 10
then
   $MaxDeliveriesToMake = 10   
   $ChosenDeliveryQTY = 10 
   $Actor1Dialog01 = 4
   jump @JustCloseHowManyDeliveriesMENU
  end
end


jump @HowManyDeliveriesMENU2


////////////////////////////////////////////////////CLOSE CHOOSE VEHICLE MENU
:JustCloseHowManyDeliveriesMENU
wait 0 
08DA: remove_panel $HowManyDeliveriesMENU   
jump @HowmanyDeliveriesToMake   ///// Jump to checker down below, to spawn the exact quantity of boxes depending of how much deliveries there are.
///////////////////

:DeleteVeh_And_CloseMENU
wait 0
00A6: destroy_car $Truck
08DA: remove_panel $HowManyDeliveriesMENU   
03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
02EB: restore_camera_with_jumpcut
0826: enable_hud 1
0581: enable_radar 1
01B4: set_player $PLAYER_CHAR can_move 1
Player.CanMove($PLAYER_CHAR) = True 
jump @Restart

////////////////////////////////////////////////////*******************



////////////////////////////////**************************************----------------------------------------------------------------------------------------------
///////////////////////////////////////// RECRUIT $Actor1 
   //////////////////////////////////////////                          A C T O R   F O L L O W   S Y S T E M  ///////////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
:Actor1FollowSystem
wait 0

if
 $Actor1 == -1
then
   return
 end
 
if
 0118: actor $Actor1 dead
then 
  return
end

if 
$MakeSashaDeliverBox1 == 1 
then
 return
end

if $Actor1FollowPlayer == 0
then 
  return 
end

//====================================================
// STATE 1: PLAYER ENTERED TRUCK - TELL SASHA TO ENTER
//====================================================
if and
    00DB: actor $PLAYER_ACTOR in_car $Truck
    80DB: not actor $Actor1 in_car $Truck
    $Actor1InCarWithPlayer == 0 // She is currently on foot and hasn't been told to enter yet
then
    // Stop any "Carrying Box" animation that might lock her body
    0687: clear_actor $Actor1 task
    wait 0
    // Send command ONCE
    05CA: AS_actor $Actor1 enter_car $Truck passenger_seat 0 time -1
    $Actor1InCarWithPlayer = 1 // Set to 1 so this block doesn't run again while she is walking to the door
    return
end

//====================================================
// STATE 2: SASHA IS FULLY INSIDE - LOCK THE STATE
//====================================================
if and
    00DB: actor $Actor1 in_car $Truck
    $Actor1InCarWithPlayer == 1
then
    $Actor1InCarWithPlayer = 2 // She is now fully seated
    return
end

//====================================================
// STATE 3: PLAYER LEFT TRUCK - TELL SASHA TO EXIT
//====================================================
if and
    80DB: not actor $PLAYER_ACTOR in_car $Truck
    $Actor1InCarWithPlayer > 0 // She is either entering or inside (State 1 or 2)
then
    0687: clear_actor $Actor1 task
    0633: AS_actor $Actor1 exit_car
    $Actor1InCarWithPlayer = 0 // Reset to On-Foot state
    return
end

//====================================================
// STATE 4: FOLLOW PLAYER ON FOOT
//====================================================
if and
    80DB: not actor $PLAYER_ACTOR in_car $Truck
    80DB: not actor $Actor1 in_car $Truck
    $Actor1InCarWithPlayer == 0
then
    if 00F2: actor $Actor1 near_actor $PLAYER_ACTOR radius 4.0 4.0 sphere 0
    then
        // Already close, do nothing or stay idle
        return
    else   
        0850: AS_actor $Actor1 follow_actor $PLAYER_ACTOR
        return
    end
end

//====================================================
// SAFETY: PLAYER IN WRONG VEHICLE
//====================================================
if and
    00DF: actor $PLAYER_ACTOR driving
    80DB: not actor $PLAYER_ACTOR in_car $Truck
then
    0AD1: show_formatted_text_highpriority "~w~I'm not paying you to drive that vehicle!" time 1500
end

return
////////////////////////////////**************************************----------------------------------------------------------------------------------------------
////////////////////////////////**************************************----------------------------------------------------------------------------------------------








////////////////////////////////////////////////////************************--------------------------------------------------------//////////////////////////////////////////////


//////////////////////////////////////////////        //// R E S E T   V A L U E S   !!!!!!!!!!!!!!//////////////////////////////////////////////        //// R E S E T   V A L U E S   !!!!!!!!!!!!!!

///////////////////MISSION FAILED CHECK GOSUB

:MissionFailedCheck0
wait 0 
// Player died
if
0118: actor $PLAYER_ACTOR dead
then
    jump @MissionFailed1
end
return




:MissionFailedCheck1
wait 0

// Player died
if
0118: actor $PLAYER_ACTOR dead
then
    jump @MissionFailed1
end

// $Actor1 // Woman start mission dies
if
0118: actor $Actor1 dead
then
    jump @MissionFailed1
end

// Truck destroyed
if 
 $Truck > -1
then
    if
    0119: car $Truck wrecked
    then
        jump @MissionFailed1
    end
end

return
/////////////////////////////////////////////// //////////////////////////////////////////////        //// R E S E T   V A L U E S   !!!!!!!!!!!!!!
:MissionFailed1
wait 0

03E5: show_text_box 'M_FAIL' // "Mission Failed!"

00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1

wait 1500

// Clean up
gosub @CheckLastDeliveredBoxExistence


// Fade OUT immediately
016A: fade 0 time 500


:MISSIONCLEANUP
wait 0
016A: fade 0 time 500
wait 600


// 2. LIMPAR OBJETOS DA MISSO (Checando se existem antes)


// Clean Drop Array Objects
if
03CA: object $DropB0 exists
then
    0108: destroy_object $DropB0
    $DropB0 = -1
end

if
03CA: object $DropB1 exists
then
    0108: destroy_object $DropB1
    $DropB1 = -1
end

if
03CA: object $DropB2 exists
then
    0108: destroy_object $DropB2
    $DropB2 = -1
end

if
03CA: object $DropB3 exists
then
    0108: destroy_object $DropB3
    $DropB3 = -1
end

if
03CA: object $DropB4 exists
then
    0108: destroy_object $DropB4
    $DropB4 = -1
end

if
03CA: object $DropB5 exists
then
    0108: destroy_object $DropB5
    $DropB5 = -1
end

if
03CA: object $DropB6 exists
then
    0108: destroy_object $DropB6
    $DropB6 = -1
end

if
03CA: object $DropB7 exists
then
    0108: destroy_object $DropB7
    $DropB7 = -1
end

if
03CA: object $DropB8 exists
then
    0108: destroy_object $DropB8
    $DropB8 = -1
end

if
03CA: object $DropB9 exists
then
    0108: destroy_object $DropB9
    $DropB9 = -1
end

if
03CA: object $DropB10 exists
then
    0108: destroy_object $DropB10
    $DropB10 = -1
end

// 5. LIMPAR ATORES (NPCs)
if
    056D: actor $SashaHusband defined
then
    009B: destroy_actor $SashaHusband
end

if 
    056D: actor $Actor1 defined
then
    009B: destroy_actor $Actor1
end

// 6. LIMPAR O VECULO (Por ltimo)



wait 200
// Reset de variveis de estado
$Truck = -1
$Actor1 = -1
$SashaHusband = -1
$BoxToSpawn = -1
$CurrentBox = -1
$Actor1InCarWithPlayer = 0
$ONMISSION = 0

03BF: set_player $PLAYER_CHAR ignored_by_everyone 0
Player.CanMove($PLAYER_CHAR) = True






Player.CanMove($PLAYER_CHAR) = true

016A: fade 1 time 1000
WAIT 2000
jump @Restart
///////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////----------
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////----------




////////////////////////////////////////////////////************************-/////////////  C H O O S E  R A N D O M  H O U S E  **************************************************------*********
////////////////////////////////////////////////////************************----------------------
:HouseVariables
wait 0

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

:HousesCurrentAvaiability 
wait 0 

$House0_Available = 1
$House1_Available = 1
$House2_Available = 1
$House3_Available = 1
$House4_Available = 1
$House5_Available = 1
$House6_Available = 1
$House7_Available = 1
$House8_Available = 1
$House9_Available = 1
$House10_Available = 1
$House11_Available = 1
$House12_Available = 1
$House13_Available = 1
$House14_Available = 1
$House15_Available = 1
$House16_Available = 1
$House17_Available = 1
$House18_Available = 1
$House19_Available = 1
$House20_Available = 1
$House21_Available = 1
$House22_Available = 1
$House23_Available = 1
$House24_Available = 1
$House25_Available = 1
$House26_Available = 1
$House27_Available = 1
$House28_Available = 1
$House29_Available = 1
$House30_Available = 1
$House31_Available = 1
$House32_Available = 1
$House33_Available = 1
$House34_Available = 1
$House35_Available = 1
$House36_Available = 1
$House37_Available = 1
$House38_Available = 1
$House39_Available = 1
$House40_Available = 1
$House41_Available = 1
$House42_Available = 1
$House43_Available = 1
$House44_Available = 1
$House45_Available = 1
$House46_Available = 1
$House47_Available = 1
$House48_Available = 1
$House49_Available = 1
$House50_Available = 1
$House51_Available = 1
$House52_Available = 1
$House53_Available = 1
$House54_Available = 1
$House55_Available = 1
$House56_Available = 1
$House57_Available = 1
$House58_Available = 1
$House59_Available = 1
$House60_Available = 1
$House61_Available = 1
$House62_Available = 1
$House63_Available = 1
$House64_Available = 1
$House65_Available = 1
$House66_Available = 1
$House67_Available = 1
$House68_Available = 1
$House69_Available = 1
$House70_Available = 1
$House71_Available = 1
$House72_Available = 1
$House73_Available = 1
$House74_Available = 1
$House75_Available = 1
$House76_Available = 1
$House77_Available = 1
$House78_Available = 1
$House79_Available = 1
$House80_Available = 1
$House81_Available = 1
$House82_Available = 1
$House83_Available = 1
$House84_Available = 1
$House85_Available = 1
$House86_Available = 1
$House87_Available = 1
$House88_Available = 1
$House89_Available = 1
$House90_Available = 1
$House91_Available = 1
$House92_Available = 1
$House93_Available = 1
$House94_Available = 1
$House95_Available = 1
$House96_Available = 1
$House97_Available = 1
$House98_Available = 1
$House99_Available = 1
$House100_Available = 1
$House101_Available = 1
$House102_Available = 1
$House103_Available = 1
$House104_Available = 1
$House105_Available = 1
$House106_Available = 1
$House107_Available = 1
$House108_Available = 1
$House109_Available = 1
$House110_Available = 1
$House111_Available = 1
$House112_Available = 1
$House113_Available = 1
$House114_Available = 1
$House115_Available = 1
$House116_Available = 1
$House117_Available = 1
$House118_Available = 1
$House119_Available = 1
$House120_Available = 1
$House121_Available = 1
$House122_Available = 1
$House123_Available = 1
$House124_Available = 1
$House125_Available = 1
$House126_Available = 1
$House127_Available = 1
$House128_Available = 1
$House129_Available = 1
$House130_Available = 1
$House131_Available = 1
$House132_Available = 1
$House133_Available = 1
$House134_Available = 1
$House135_Available = 1
$House136_Available = 1
$House137_Available = 1
$House138_Available = 1
$House139_Available = 1
$House140_Available = 1
$House141_Available = 1
$House142_Available = 1
$House143_Available = 1
$House144_Available = 1
$House145_Available = 1
$House146_Available = 1
$House147_Available = 1
$House148_Available = 1
$House149_Available = 1
$House150_Available = 1
$House151_Available = 1
$House152_Available = 1
$House153_Available = 1
$House154_Available = 1
$House155_Available = 1
$House156_Available = 1
$House157_Available = 1
$House158_Available = 1
$House159_Available = 1
$House160_Available = 1
$House161_Available = 1
$House162_Available = 1
$House163_Available = 1
$House164_Available = 1
$House165_Available = 1
$House166_Available = 1
$House167_Available = 1
$House168_Available = 1
$House169_Available = 1
$House170_Available = 1
$House171_Available = 1
$House172_Available = 1
$House173_Available = 1
$House174_Available = 1
$House175_Available = 1
$House176_Available = 1
$House177_Available = 1
$House178_Available = 1
$House179_Available = 1
$House180_Available = 1
$House181_Available = 1
$House182_Available = 1
$House183_Available = 1
$House184_Available = 1
$House185_Available = 1
$House186_Available = 1
$House187_Available = 1
$House188_Available = 1
$House189_Available = 1
$House190_Available = 1
$House191_Available = 1
$House192_Available = 1
$House193_Available = 1
$House194_Available = 1
$House195_Available = 1
$House196_Available = 1
$House197_Available = 1
$House198_Available = 1
$House199_Available = 1
$House200_Available = 1
$House201_Available = 1
$House202_Available = 1
$House203_Available = 1
$House204_Available = 1
$House205_Available = 1
$House206_Available = 1
$House207_Available = 1
$House208_Available = 1
$House209_Available = 1
$House210_Available = 1
$House211_Available = 1
$House212_Available = 1
$House213_Available = 1
$House214_Available = 1
$House215_Available = 1
$House216_Available = 1
$House217_Available = 1
$House218_Available = 1
$House219_Available = 1
$House220_Available = 1
$House221_Available = 1
$House222_Available = 1
$House223_Available = 1
$House224_Available = 1
$House225_Available = 1
$House226_Available = 1
$House227_Available = 1
$House228_Available = 1
$House229_Available = 1
$House230_Available = 1
$House231_Available = 1
$House232_Available = 1


////////////////////////////////////////////////////////////////////////////////////////////////////*********************************************************************************

:ChooseRandomHouseVariables
wait 0 
///////  $MaxDeliveriesToMake
//////  $TempChosenDeliveries
/////////////////////////////////////////Deliveries limit is reached - then, start mission
if
  $TempChosenDeliveries == $MaxDeliveriesToMake  // (float)
then
   jump @StartMission3   //// Start mission for real!
end   

/////////////////////////////////////////////////Deliveries limit is not reached
if
  not $TempChosenDeliveries == $MaxDeliveriesToMake  // (float)
then
    0209: $CurrentHouseToDeliver = random_int_in_ranges 0 232 /// The current random number chosen, which corresponds to a house location
    jump @Gosub01     
    :ContinueAfterGosubs
    wait 0
    $TempChosenDeliveries += 1    /// Add (+1) to $TempNumberOfDeliveriesChosen
    jump @ChooseRandomHouseVariables
end


:Gosub01 //// Check if house wasn't already taken
wait 0 
jump @HouseAvailability

:Gosub02 //// Pick this house as a location
wait 0 
jump @PickADeliveryLoc  


:Gosub03 //// Create a different marker and checkpoint depending of the location, so every loc will have its own sphere and checkpoint
wait 0 
jump @Checksequence  


/////////////////////////////////////////////////////////////////////////////////////////////
:Checksequence
wait 0 
if 
 $TempChosenDeliveries == 0
 then
     03BC: $H0 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker0 = create_checkpoint_at $DestX $DestY $DestZ
     0087: $H0_X = $DestX
     0087: $H0_Y = $DestY
     0087: $H0_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 1
 then
     03BC: $H1 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker1 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H1_X = $DestX
     0087: $H1_Y = $DestY
     0087: $H1_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 2
 then
     03BC: $H2 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker2 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H2_X = $DestX
     0087: $H2_Y = $DestY
     0087: $H2_Z = $DestZ
     wait 0  
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 3
 then
     03BC: $H3 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker3 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H3_X = $DestX
     0087: $H3_Y = $DestY
     0087: $H3_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 4
 then
     03BC: $H4 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker4 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H4_X = $DestX
     0087: $H4_Y = $DestY
     0087: $H4_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs  
end     

if 
 $TempChosenDeliveries == 5
 then
     03BC: $H5 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker5 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H5_X = $DestX
     0087: $H5_Y = $DestY
     0087: $H5_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 6
 then
     03BC: $H6 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker6 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H6_X = $DestX
     0087: $H6_Y = $DestY
     0087: $H6_Z = $DestZ
     wait 250
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 7
 then
     03BC: $H7 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker7 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H7_X = $DestX
     0087: $H7_Y = $DestY
     0087: $H7_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 8
 then
     03BC: $H8 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker8 = create_checkpoint_at $DestX $DestY $DestZ 
     0087: $H8_X = $DestX
     0087: $H8_Y = $DestY
     0087: $H8_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 9
 then
     03BC: $H9 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker9 = create_checkpoint_at $DestX $DestY $DestZ     
     0087: $H9_X = $DestX
     0087: $H9_Y = $DestY
     0087: $H9_Z = $DestZ    
     wait 0
     jump @ContinueAfterGosubs
end     

if 
 $TempChosenDeliveries == 10
 then
     03BC: $H10 = create_sphere_at $DestX $DestY $DestZ radius 2.0
     018A: $HouseFrontMarker10 = create_checkpoint_at $DestX $DestY $DestZ  
     0087: $H10_X = $DestX
     0087: $H10_Y = $DestY
     0087: $H10_Z = $DestZ
     wait 0
     jump @ContinueAfterGosubs
end     

jump @ContinueAfterGosubs



///////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<HOUSE AVALIABILITY 
:HouseAvailability
wait 0 

if 
    $CurrentHouseToDeliver == 0
then
    if
        $House0_Available == 1
    then
        $House0_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 1
then
    if
        $House1_Available == 1
    then
        $House1_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 2
then
    if
        $House2_Available == 1
    then
        $House2_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 3
then
    if
        $House3_Available == 1
    then
        $House3_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 4
then
    if
        $House4_Available == 1
    then
        $House4_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 5
then
    if
        $House5_Available == 1
    then
        $House5_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 6
then
    if
        $House6_Available == 1
    then
        $House6_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 7
then
    if
        $House7_Available == 1
    then
        $House7_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 8
then
    if
        $House8_Available == 1
    then
        $House8_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 9
then
    if
        $House9_Available == 1
    then
        $House9_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 10
then
    if
        $House10_Available == 1
    then
        $House10_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 11
then
    if
        $House11_Available == 1
    then
        $House11_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 12
then
    if
        $House12_Available == 1
    then
        $House12_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 13
then
    if
        $House13_Available == 1
    then
        $House13_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 14
then
    if
        $House14_Available == 1
    then
        $House14_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 15
then
    if
        $House15_Available == 1
    then
        $House15_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 16
then
    if
        $House16_Available == 1
    then
        $House16_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 17
then
    if
        $House17_Available == 1
    then
        $House17_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 18
then
    if
        $House18_Available == 1
    then
        $House18_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 19
then
    if
        $House19_Available == 1
    then
        $House19_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 20
then
    if
        $House20_Available == 1
    then
        $House20_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 21
then
    if
        $House21_Available == 1
    then
        $House21_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 22
then
    if
        $House22_Available == 1
    then
        $House22_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 23
then
    if
        $House23_Available == 1
    then
        $House23_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 24
then
    if
        $House24_Available == 1
    then
        $House24_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 25
then
    if
        $House25_Available == 1
    then
        $House25_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 26
then
    if
        $House26_Available == 1
    then
        $House26_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 27
then
    if
        $House27_Available == 1
    then
        $House27_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 28
then
    if
        $House28_Available == 1
    then
        $House28_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 29
then
    if
        $House29_Available == 1
    then
        $House29_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 30
then
    if
        $House30_Available == 1
    then
        $House30_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 31
then
    if
        $House31_Available == 1
    then
        $House31_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 32
then
    if
        $House32_Available == 1
    then
        $House32_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 33
then
    if
        $House33_Available == 1
    then
        $House33_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 34
then
    if
        $House34_Available == 1
    then
        $House34_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 35
then
    if
        $House35_Available == 1
    then
        $House35_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 36
then
    if
        $House36_Available == 1
    then
        $House36_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 37
then
    if
        $House37_Available == 1
    then
        $House37_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 38
then
    if
        $House38_Available == 1
    then
        $House38_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 39
then
    if
        $House39_Available == 1
    then
        $House39_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 40
then
    if
        $House40_Available == 1
    then
        $House40_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 41
then
    if
        $House41_Available == 1
    then
        $House41_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 42
then
    if
        $House42_Available == 1
    then
        $House42_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 43
then
    if
        $House43_Available == 1
    then
        $House43_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 44
then
    if
        $House44_Available == 1
    then
        $House44_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 45
then
    if
        $House45_Available == 1
    then
        $House45_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 46
then
    if
        $House46_Available == 1
    then
        $House46_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 47
then
    if
        $House47_Available == 1
    then
        $House47_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 48
then
    if
        $House48_Available == 1
    then
        $House48_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 49
then
    if
        $House49_Available == 1
    then
        $House49_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 50
then
    if
        $House50_Available == 1
    then
        $House50_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 51
then
    if
        $House51_Available == 1
    then
        $House51_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 52
then
    if
        $House52_Available == 1
    then
        $House52_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 53
then
    if
        $House53_Available == 1
    then
        $House53_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 54
then
    if
        $House54_Available == 1
    then
        $House54_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 55
then
    if
        $House55_Available == 1
    then
        $House55_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 56
then
    if
        $House56_Available == 1
    then
        $House56_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 57
then
    if
        $House57_Available == 1
    then
        $House57_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 58
then
    if
        $House58_Available == 1
    then
        $House58_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 59
then
    if
        $House59_Available == 1
    then
        $House59_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 60
then
    if
        $House60_Available == 1
    then
        $House60_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 61
then
    if
        $House61_Available == 1
    then
        $House61_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 62
then
    if
        $House62_Available == 1
    then
        $House62_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 63
then
    if
        $House63_Available == 1
    then
        $House63_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 64
then
    if
        $House64_Available == 1
    then
        $House64_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 65
then
    if
        $House65_Available == 1
    then
        $House65_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 66
then
    if
        $House66_Available == 1
    then
        $House66_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 67
then
    if
        $House67_Available == 1
    then
        $House67_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 68
then
    if
        $House68_Available == 1
    then
        $House68_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 69
then
    if
        $House69_Available == 1
    then
        $House69_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 70
then
    if
        $House70_Available == 1
    then
        $House70_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 71
then
    if
        $House71_Available == 1
    then
        $House71_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 72
then
    if
        $House72_Available == 1
    then
        $House72_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 73
then
    if
        $House73_Available == 1
    then
        $House73_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 74
then
    if
        $House74_Available == 1
    then
        $House74_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 75
then
    if
        $House75_Available == 1
    then
        $House75_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 76
then
    if
        $House76_Available == 1
    then
        $House76_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 77
then
    if
        $House77_Available == 1
    then
        $House77_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 78
then
    if
        $House78_Available == 1
    then
        $House78_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 79
then
    if
        $House79_Available == 1
    then
        $House79_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 80
then
    if
        $House80_Available == 1
    then
        $House80_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 81
then
    if
        $House81_Available == 1
    then
        $House81_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 82
then
    if
        $House82_Available == 1
    then
        $House82_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 83
then
    if
        $House83_Available == 1
    then
        $House83_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 84
then
    if
        $House84_Available == 1
    then
        $House84_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 85
then
    if
        $House85_Available == 1
    then
        $House85_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 86
then
    if
        $House86_Available == 1
    then
        $House86_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 87
then
    if
        $House87_Available == 1
    then
        $House87_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 88
then
    if
        $House88_Available == 1
    then
        $House88_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 89
then
    if
        $House89_Available == 1
    then
        $House89_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 90
then
    if
        $House90_Available == 1
    then
        $House90_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 91
then
    if
        $House91_Available == 1
    then
        $House91_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 92
then
    if
        $House92_Available == 1
    then
        $House92_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 93
then
    if
        $House93_Available == 1
    then
        $House93_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 94
then
    if
        $House94_Available == 1
    then
        $House94_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 95
then
    if
        $House95_Available == 1
    then
        $House95_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 96
then
    if
        $House96_Available == 1
    then
        $House96_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 97
then
    if
        $House97_Available == 1
    then
        $House97_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 98
then
    if
        $House98_Available == 1
    then
        $House98_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 99
then
    if
        $House99_Available == 1
    then
        $House99_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 100
then
    if
        $House100_Available == 1
    then
        $House100_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 101
then
    if
        $House101_Available == 1
    then
        $House101_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 102
then
    if
        $House102_Available == 1
    then
        $House102_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 103
then
    if
        $House103_Available == 1
    then
        $House103_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 104
then
    if
        $House104_Available == 1
    then
        $House104_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 105
then
    if
        $House105_Available == 1
    then
        $House105_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 106
then
    if
        $House106_Available == 1
    then
        $House106_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 107
then
    if
        $House107_Available == 1
    then
        $House107_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 108
then
    if
        $House108_Available == 1
    then
        $House108_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 109
then
    if
        $House109_Available == 1
    then
        $House109_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 110
then
    if
        $House110_Available == 1
    then
        $House110_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 111
then
    if
        $House111_Available == 1
    then
        $House111_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 112
then
    if
        $House112_Available == 1
    then
        $House112_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 113
then
    if
        $House113_Available == 1
    then
        $House113_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 114
then
    if
        $House114_Available == 1
    then
        $House114_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 115
then
    if
        $House115_Available == 1
    then
        $House115_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 116
then
    if
        $House116_Available == 1
    then
        $House116_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 117
then
    if
        $House117_Available == 1
    then
        $House117_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 118
then
    if
        $House118_Available == 1
    then
        $House118_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 119
then
    if
        $House119_Available == 1
    then
        $House119_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 120
then
    if
        $House120_Available == 1
    then
        $House120_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 121
then
    if
        $House121_Available == 1
    then
        $House121_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 122
then
    if
        $House122_Available == 1
    then
        $House122_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 123
then
    if
        $House123_Available == 1
    then
        $House123_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 124
then
    if
        $House124_Available == 1
    then
        $House124_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 125
then
    if
        $House125_Available == 1
    then
        $House125_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 126
then
    if
        $House126_Available == 1
    then
        $House126_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 127
then
    if
        $House127_Available == 1
    then
        $House127_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 128
then
    if
        $House128_Available == 1
    then
        $House128_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 129
then
    if
        $House129_Available == 1
    then
        $House129_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 130
then
    if
        $House130_Available == 1
    then
        $House130_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 131
then
    if
        $House131_Available == 1
    then
        $House131_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 132
then
    if
        $House132_Available == 1
    then
        $House132_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 133
then
    if
        $House133_Available == 1
    then
        $House133_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 134
then
    if
        $House134_Available == 1
    then
        $House134_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 135
then
    if
        $House135_Available == 1
    then
        $House135_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 136
then
    if
        $House136_Available == 1
    then
        $House136_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 137
then
    if
        $House137_Available == 1
    then
        $House137_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 138
then
    if
        $House138_Available == 1
    then
        $House138_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 139
then
    if
        $House139_Available == 1
    then
        $House139_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 140
then
    if
        $House140_Available == 1
    then
        $House140_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 141
then
    if
        $House141_Available == 1
    then
        $House141_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 142
then
    if
        $House142_Available == 1
    then
        $House142_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 143
then
    if
        $House143_Available == 1
    then
        $House143_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 144
then
    if
        $House144_Available == 1
    then
        $House144_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 145
then
    if
        $House145_Available == 1
    then
        $House145_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 146
then
    if
        $House146_Available == 1
    then
        $House146_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 147
then
    if
        $House147_Available == 1
    then
        $House147_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 148
then
    if
        $House148_Available == 1
    then
        $House148_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 149
then
    if
        $House149_Available == 1
    then
        $House149_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 150
then
    if
        $House150_Available == 1
    then
        $House150_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 151
then
    if
        $House151_Available == 1
    then
        $House151_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 152
then
    if
        $House152_Available == 1
    then
        $House152_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 153
then
    if
        $House153_Available == 1
    then
        $House153_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 154
then
    if
        $House154_Available == 1
    then
        $House154_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 155
then
    if
        $House155_Available == 1
    then
        $House155_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 156
then
    if
        $House156_Available == 1
    then
        $House156_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 157
then
    if
        $House157_Available == 1
    then
        $House157_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 158
then
    if
        $House158_Available == 1
    then
        $House158_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 159
then
    if
        $House159_Available == 1
    then
        $House159_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 160
then
    if
        $House160_Available == 1
    then
        $House160_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 161
then
    if
        $House161_Available == 1
    then
        $House161_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 162
then
    if
        $House162_Available == 1
    then
        $House162_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 163
then
    if
        $House163_Available == 1
    then
        $House163_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 164
then
    if
        $House164_Available == 1
    then
        $House164_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 165
then
    if
        $House165_Available == 1
    then
        $House165_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 166
then
    if
        $House166_Available == 1
    then
        $House166_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 167
then
    if
        $House167_Available == 1
    then
        $House167_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 168
then
    if
        $House168_Available == 1
    then
        $House168_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 169
then
    if
        $House169_Available == 1
    then
        $House169_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 170
then
    if
        $House170_Available == 1
    then
        $House170_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 171
then
    if
        $House171_Available == 1
    then
        $House171_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 172
then
    if
        $House172_Available == 1
    then
        $House172_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 173
then
    if
        $House173_Available == 1
    then
        $House173_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 174
then
    if
        $House174_Available == 1
    then
        $House174_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 175
then
    if
        $House175_Available == 1
    then
        $House175_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 176
then
    if
        $House176_Available == 1
    then
        $House176_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 177
then
    if
        $House177_Available == 1
    then
        $House177_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 178
then
    if
        $House178_Available == 1
    then
        $House178_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 179
then
    if
        $House179_Available == 1
    then
        $House179_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 180
then
    if
        $House180_Available == 1
    then
        $House180_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 181
then
    if
        $House181_Available == 1
    then
        $House181_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 182
then
    if
        $House182_Available == 1
    then
        $House182_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 183
then
    if
        $House183_Available == 1
    then
        $House183_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 184
then
    if
        $House184_Available == 1
    then
        $House184_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 185
then
    if
        $House185_Available == 1
    then
        $House185_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 186
then
    if
        $House186_Available == 1
    then
        $House186_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 187
then
    if
        $House187_Available == 1
    then
        $House187_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 188
then
    if
        $House188_Available == 1
    then
        $House188_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 189
then
    if
        $House189_Available == 1
    then
        $House189_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 190
then
    if
        $House190_Available == 1
    then
        $House190_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 191
then
    if
        $House191_Available == 1
    then
        $House191_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 192
then
    if
        $House192_Available == 1
    then
        $House192_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 193
then
    if
        $House193_Available == 1
    then
        $House193_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 194
then
    if
        $House194_Available == 1
    then
        $House194_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 195
then
    if
        $House195_Available == 1
    then
        $House195_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 196
then
    if
        $House196_Available == 1
    then
        $House196_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 197
then
    if
        $House197_Available == 1
    then
        $House197_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 198
then
    if
        $House198_Available == 1
    then
        $House198_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 199
then
    if
        $House199_Available == 1
    then
        $House199_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 200
then
    if
        $House200_Available == 1
    then
        $House200_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 201
then
    if
        $House201_Available == 1
    then
        $House201_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 202
then
    if
        $House202_Available == 1
    then
        $House202_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 203
then
    if
        $House203_Available == 1
    then
        $House203_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 204
then
    if
        $House204_Available == 1
    then
        $House204_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 205
then
    if
        $House205_Available == 1
    then
        $House205_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 206
then
    if
        $House206_Available == 1
    then
        $House206_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 207
then
    if
        $House207_Available == 1
    then
        $House207_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 208
then
    if
        $House208_Available == 1
    then
        $House208_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 209
then
    if
        $House209_Available == 1
    then
        $House209_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 210
then
    if
        $House210_Available == 1
    then
        $House210_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 211
then
    if
        $House211_Available == 1
    then
        $House211_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 212
then
    if
        $House212_Available == 1
    then
        $House212_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 213
then
    if
        $House213_Available == 1
    then
        $House213_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 214
then
    if
        $House214_Available == 1
    then
        $House214_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 215
then
    if
        $House215_Available == 1
    then
        $House215_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 216
then
    if
        $House216_Available == 1
    then
        $House216_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 217
then
    if
        $House217_Available == 1
    then
        $House217_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 218
then
    if
        $House218_Available == 1
    then
        $House218_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 219
then
    if
        $House219_Available == 1
    then
        $House219_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 220
then
    if
        $House220_Available == 1
    then
        $House220_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 221
then
    if
        $House221_Available == 1
    then
        $House221_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 222
then
    if
        $House222_Available == 1
    then
        $House222_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 223
then
    if
        $House223_Available == 1
    then
        $House223_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 224
then
    if
        $House224_Available == 1
    then
        $House224_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 225
then
    if
        $House225_Available == 1
    then
        $House225_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 226
then
    if
        $House226_Available == 1
    then
        $House226_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 227
then
    if
        $House227_Available == 1
    then
        $House227_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 228
then
    if
        $House228_Available == 1
    then
        $House228_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 229
then
    if
        $House229_Available == 1
    then
        $House229_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 230
then
    if
        $House230_Available == 1
    then
        $House230_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 231
then
    if
        $House231_Available == 1
    then
        $House231_Available = 0
        jump @Gosub02
    end  
end

if 
    $CurrentHouseToDeliver == 232
then
    if
        $House232_Available == 1
    then
        $House232_Available = 0
        jump @Gosub02
    end  
end

jf @ChooseRandomHouseVariables

/////////////////////////////////////////////////////////////////////////////////////////////////////////*****************************************

/////////////////////////////////////////////////////////////////////////////////////////////////////////*********************************************************////////////

///////////////////////////


:PickADeliveryLoc
wait 0 

if $CurrentHouseToDeliver == 0
then
    $DestX = 2522.9211
    $DestY = -1679.4105
    $DestZ = 15.4970
    jump @Gosub03
end

if $CurrentHouseToDeliver == 1
then
    $DestX = 2513.4919
    $DestY = -1650.3929
    $DestZ = 14.3557
    jump @Gosub03
end

if $CurrentHouseToDeliver == 2
then
    $DestX = 2469.3369
    $DestY = -1646.5956
    $DestZ = 13.7801
    jump @Gosub03
end

if $CurrentHouseToDeliver == 3
then
    $DestX = 2392.9243
    $DestY = -1646.3313
    $DestZ = 13.9051
    jump @Gosub03
end

if $CurrentHouseToDeliver == 4
then
    $DestX = 2368.2148
    $DestY = -1675.1520
    $DestZ = 14.1682
    jump @Gosub03
end

if $CurrentHouseToDeliver == 5
then
    $DestX = 2326.8884
    $DestY = -1681.8837
    $DestZ = 14.9297
    jump @Gosub03
end

if $CurrentHouseToDeliver == 6
then
    $DestX = 2307.1304
    $DestY = -1678.4099
    $DestZ = 14.0012
    jump @Gosub03
end

if $CurrentHouseToDeliver == 7
then
    $DestX = 2282.3159
    $DestY = -1641.4520
    $DestZ = 15.8898
    jump @Gosub03
end

if $CurrentHouseToDeliver == 8
then
    $DestX = 2267.9214
    $DestY = -1670.6597
    $DestZ = 15.3594
    jump @Gosub03
end

if $CurrentHouseToDeliver == 9
then
    $DestX = 2178.3403
    $DestY = -1660.1930
    $DestZ = 14.9783
    jump @Gosub03
end

if $CurrentHouseToDeliver == 10
then
    $DestX = 2166.2214
    $DestY = -1671.7130
    $DestZ = 15.0739
    jump @Gosub03
end

if $CurrentHouseToDeliver == 11
then
    $DestX = 2144.8816
    $DestY = -1688.7180
    $DestZ = 15.0859
    jump @Gosub03
end

if $CurrentHouseToDeliver == 12
then
    $DestX = 2144.0422
    $DestY = -1663.1857
    $DestZ = 15.0859
    jump @Gosub03
end

if $CurrentHouseToDeliver == 13
then
    $DestX = 2185.6624
    $DestY = -1814.8158
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 14
then
    $DestX = 2172.3813
    $DestY = -1819.5652
    $DestZ = 16.1406
    jump @Gosub03
end

if $CurrentHouseToDeliver == 15
then
    $DestX = 2164.8105
    $DestY = -1819.3723
    $DestZ = 16.1406
    jump @Gosub03
end

if $CurrentHouseToDeliver == 16
then
    $DestX = 2158.3501
    $DestY = -1819.5917
    $DestZ = 16.1406
    jump @Gosub03
end

if $CurrentHouseToDeliver == 17
then
    $DestX = 2147.0457
    $DestY = -1815.1621
    $DestZ = 16.1406
    jump @Gosub03
end

if $CurrentHouseToDeliver == 18
then
    $DestX = 2147.3457
    $DestY = -1808.9474
    $DestZ = 16.1406
    jump @Gosub03
end

if $CurrentHouseToDeliver == 19
then
    $DestX = 2141.2166
    $DestY = -1802.1218
    $DestZ = 16.1475
    jump @Gosub03
end

if $CurrentHouseToDeliver == 20
then
    $DestX = 2275.8550
    $DestY = -1785.8967
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 21
then
    $DestX = 2247.1785
    $DestY = -1796.0066
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 22
then
    $DestX = 2307.6304
    $DestY = -1785.5662
    $DestZ = 13.5575
    jump @Gosub03
end

if $CurrentHouseToDeliver == 23
then
    $DestX = 2290.1316
    $DestY = -1796.3342
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 24
then
    $DestX = 2322.2705
    $DestY = -1795.7539
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 25
then
    $DestX = 2345.5125
    $DestY = -1785.9261
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 26
then
    $DestX = 2380.6794
    $DestY = -1785.8937
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 27
then
    $DestX = 2360.3408
    $DestY = -1795.7604
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 28
then
    $DestX = 2385.6672
    $DestY = -1712.1169
    $DestZ = 14.2422
    jump @Gosub03
end

if $CurrentHouseToDeliver == 29
then
    $DestX = 2402.5996
    $DestY = -1715.1665
    $DestZ = 14.1328
    jump @Gosub03
end

if $CurrentHouseToDeliver == 30
then
    $DestX = 2423.3196
    $DestY = -1886.7599
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 31
then
    $DestX = 2446.3262
    $DestY = -1901.7291
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 32
then
    $DestX = 2423.9412
    $DestY = -1922.4395
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 33
then
    $DestX = 2435.6833
    $DestY = -1922.6857
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 34
then
    $DestX = 2444.0913
    $DestY = -1942.0543
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 35
then
    $DestX = 2439.0798
    $DestY = -1942.0107
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 36
then
    $DestX = 2433.9775
    $DestY = -1941.7380
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 37
then
    $DestX = 2463.1135
    $DestY = -1957.5521
    $DestZ = 16.7929
    jump @Gosub03
end

if $CurrentHouseToDeliver == 38
then
    $DestX = 2499.2656
    $DestY = -1963.2920
    $DestZ = 16.7578
    jump @Gosub03
end

if $CurrentHouseToDeliver == 39
then
    $DestX = 2505.4229
    $DestY = -1958.7496
    $DestZ = 13.5810
    jump @Gosub03
end

if $CurrentHouseToDeliver == 40
then
    $DestX = 2508.9719
    $DestY = -1955.5178
    $DestZ = 13.6149
    jump @Gosub03
end

if $CurrentHouseToDeliver == 41
then
    $DestX = 2486.4045
    $DestY = -2021.5529
    $DestZ = 13.9988
    jump @Gosub03
end

if $CurrentHouseToDeliver == 42
then
    $DestX = 2465.4045
    $DestY = -2020.7938
    $DestZ = 14.1242
    jump @Gosub03
end

if $CurrentHouseToDeliver == 43
then
    $DestX = 2437.9700
    $DestY = -2020.8461
    $DestZ = 13.9025
    jump @Gosub03
end

if $CurrentHouseToDeliver == 44
then
    $DestX = 2465.1150
    $DestY = -1995.7504
    $DestZ = 14.0193
    jump @Gosub03
end

if $CurrentHouseToDeliver == 45
then
    $DestX = 2508.3103
    $DestY = -1998.5732
    $DestZ = 13.9025
    jump @Gosub03
end

if $CurrentHouseToDeliver == 46
then
    $DestX = 2524.3210
    $DestY = -1998.3380
    $DestZ = 14.1131
    jump @Gosub03
end

if $CurrentHouseToDeliver == 47
then
    $DestX = 2522.7117
    $DestY = -2019.0409
    $DestZ = 14.0744
    jump @Gosub03
end

if $CurrentHouseToDeliver == 48
then
    $DestX = 2508.1357
    $DestY = -2020.7201
    $DestZ = 14.2101
    jump @Gosub03
end

if $CurrentHouseToDeliver == 49
then
    $DestX = 2486.6794
    $DestY = -2021.1617
    $DestZ = 13.9988
    jump @Gosub03
end

if $CurrentHouseToDeliver == 50
then
    $DestX = 1992.3069
    $DestY = -2101.1492
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 51
then
    $DestX = 1970.7770
    $DestY = -2074.7812
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 52
then
    $DestX = 1976.5703
    $DestY = -2046.5713
    $DestZ = 13.5471
    jump @Gosub03
end

if $CurrentHouseToDeliver == 53
then
    $DestX = 1951.4487
    $DestY = -2041.6895
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 54
then
    $DestX = 1907.5010
    $DestY = -2041.0880
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 55
then
    $DestX = 1898.1274
    $DestY = -2028.9637
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 56
then
    $DestX = 1913.5333
    $DestY = -2019.9788
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 57
then
    $DestX = 1901.8274
    $DestY = -2019.5349
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 58
then
    $DestX = 1877.6980
    $DestY = -2000.8925
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 59
then
    $DestX = 1852.7661
    $DestY = -1990.4976
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 60
then
    $DestX = 1802.0787
    $DestY = -2099.3940
    $DestZ = 14.0210
    jump @Gosub03
end

if $CurrentHouseToDeliver == 61
then
    $DestX = 1804.0729
    $DestY = -2124.9036
    $DestZ = 13.9424
    jump @Gosub03
end

if $CurrentHouseToDeliver == 62
then
    $DestX = 1782.0316
    $DestY = -2126.3918
    $DestZ = 14.0679
    jump @Gosub03
end

if $CurrentHouseToDeliver == 63
then
    $DestX = 1762.5928
    $DestY = -2102.2537
    $DestZ = 13.8570
    jump @Gosub03
end

if $CurrentHouseToDeliver == 64
then
    $DestX = 1734.8147
    $DestY = -2130.3608
    $DestZ = 14.0210
    jump @Gosub03
end

if $CurrentHouseToDeliver == 65
then
    $DestX = 1711.4082
    $DestY = -2101.2339
    $DestZ = 14.0210
    jump @Gosub03
end

if $CurrentHouseToDeliver == 66
then
    $DestX = 1673.6979
    $DestY = -2122.4846
    $DestZ = 14.1460
    jump @Gosub03
end

if $CurrentHouseToDeliver == 67
then
    $DestX = 1667.2649
    $DestY = -2106.9377
    $DestZ = 14.0723
    jump @Gosub03
end

if $CurrentHouseToDeliver == 68
then
    $DestX = 2014.8135
    $DestY = -1732.8234
    $DestZ = 14.2344
    jump @Gosub03
end

if $CurrentHouseToDeliver == 69
then
    $DestX = 2014.7915
    $DestY = -1716.9901
    $DestZ = 13.5547
    jump @Gosub03
end

if $CurrentHouseToDeliver == 70
then
    $DestX = 2017.5592
    $DestY = -1703.3239
    $DestZ = 14.2344
    jump @Gosub03
end

if $CurrentHouseToDeliver == 71
then
    $DestX = 1981.1459
    $DestY = -1718.9398
    $DestZ = 17.0303
    jump @Gosub03
end

if $CurrentHouseToDeliver == 72
then
    $DestX = 1973.3774
    $DestY = -1706.1921
    $DestZ = 15.9688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 73
then
    $DestX = 1969.2048
    $DestY = -1705.6658
    $DestZ = 15.9688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 74
then
    $DestX = 1969.5231
    $DestY = -1671.6671
    $DestZ = 15.9688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 75
then
    $DestX = 1978.7690
    $DestY = -1671.4121
    $DestZ = 16.1876
    jump @Gosub03
end

if $CurrentHouseToDeliver == 76
then
    $DestX = 1981.9838
    $DestY = -1683.1123
    $DestZ = 17.0541
    jump @Gosub03
end

if $CurrentHouseToDeliver == 77
then
    $DestX = 2013.5792
    $DestY = -1656.3741
    $DestZ = 14.1363
    jump @Gosub03
end

if $CurrentHouseToDeliver == 78
then
    $DestX = 2016.2777
    $DestY = -1641.8636
    $DestZ = 13.7824
    jump @Gosub03
end

if $CurrentHouseToDeliver == 79
then
    $DestX = 1986.7557
    $DestY = -1605.4894
    $DestZ = 13.5307
    jump @Gosub03
end

if $CurrentHouseToDeliver == 80
then
    $DestX = 1972.6785
    $DestY = -1633.9448
    $DestZ = 15.9688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 81
then
    $DestX = 1976.2142
    $DestY = -1634.1759
    $DestZ = 18.5690
    jump @Gosub03
end

if $CurrentHouseToDeliver == 82
then
    $DestX = 1910.0364
    $DestY = -1597.4725
    $DestZ = 14.3062
    jump @Gosub03
end

if $CurrentHouseToDeliver == 83
then
    $DestX = 1863.7510
    $DestY = -1597.2798
    $DestZ = 14.3062
    jump @Gosub03
end

if $CurrentHouseToDeliver == 84
then
    $DestX = 1738.8773
    $DestY = -1582.4852
    $DestZ = 14.1552
    jump @Gosub03
end

if $CurrentHouseToDeliver == 85
then
    $DestX = 1684.8478
    $DestY = -1582.4127
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 86
then
    $DestX = 1670.5453
    $DestY = -1581.9576
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 87
then
    $DestX = 1648.6791
    $DestY = -1562.3275
    $DestZ = 13.5400
    jump @Gosub03
end

if $CurrentHouseToDeliver == 88
then
    $DestX = 1667.5745
    $DestY = -1558.8051
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 89
then
    $DestX = 1667.8043
    $DestY = -1522.3066
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 90
then
    $DestX = 1667.7528
    $DestY = -1498.2831
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 91
then
    $DestX = 1648.3267
    $DestY = -1485.9762
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 92
then
    $DestX = 1648.6895
    $DestY = -1469.5636
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 93
then
    $DestX = 1632.7563
    $DestY = -1450.4307
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 94
then
    $DestX = 1616.5714
    $DestY = -1450.0831
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 95
then
    $DestX = 1692.4441
    $DestY = -1458.7444
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 96
then
    $DestX = 1675.4987
    $DestY = -1462.4716
    $DestZ = 13.6719
    jump @Gosub03
end

if $CurrentHouseToDeliver == 97
then
    $DestX = 1738.5579
    $DestY = -1452.9126
    $DestZ = 13.5513
    jump @Gosub03
end

if $CurrentHouseToDeliver == 98
then
    $DestX = 1747.9867
    $DestY = -1460.9836
    $DestZ = 13.5247
    jump @Gosub03
end

if $CurrentHouseToDeliver == 99
then
    $DestX = 2151.8740
    $DestY = -1446.3792
    $DestZ = 25.7746
    jump @Gosub03
end

if $CurrentHouseToDeliver == 100
then
    $DestX = 2148.4062
    $DestY = -1434.1484
    $DestZ = 25.5391
    jump @Gosub03
end

if $CurrentHouseToDeliver == 101
then
    $DestX = 2150.0044
    $DestY = -1419.0815
    $DestZ = 25.9219
    jump @Gosub03
end

if $CurrentHouseToDeliver == 102
then
    $DestX = 2150.6055
    $DestY = -1400.5299
    $DestZ = 25.7980
    jump @Gosub03
end

if $CurrentHouseToDeliver == 103
then
    $DestX = 2106.4871
    $DestY = -1359.5146
    $DestZ = 23.9844
    jump @Gosub03
end

if $CurrentHouseToDeliver == 104
then
    $DestX = 2129.8916
    $DestY = -1363.1504
    $DestZ = 25.5463
    jump @Gosub03
end

if $CurrentHouseToDeliver == 105
then
    $DestX = 2147.5457
    $DestY = -1366.9338
    $DestZ = 25.6418
    jump @Gosub03
end

if $CurrentHouseToDeliver == 106
then
    $DestX = 2176.4832
    $DestY = -1333.5409
    $DestZ = 23.9844
    jump @Gosub03
end

if $CurrentHouseToDeliver == 107
then
    $DestX = 2176.3354
    $DestY = -1325.4084
    $DestZ = 23.9844
    jump @Gosub03
end

if $CurrentHouseToDeliver == 108
then
    $DestX = 2147.8325
    $DestY = -1319.3518
    $DestZ = 25.7433
    jump @Gosub03
end

if $CurrentHouseToDeliver == 109
then
    $DestX = 2126.7891
    $DestY = -1320.1896
    $DestZ = 26.6242
    jump @Gosub03
end

if $CurrentHouseToDeliver == 110
then
    $DestX = 2100.9634
    $DestY = -1321.3593
    $DestZ = 25.9531
    jump @Gosub03
end

if $CurrentHouseToDeliver == 111
then
    $DestX = 2091.2288
    $DestY = -1278.1381
    $DestZ = 26.1797
    jump @Gosub03
end

if $CurrentHouseToDeliver == 112
then
    $DestX = 2460.2649
    $DestY = -1318.4147
    $DestZ = 24.0000
    jump @Gosub03
end

if $CurrentHouseToDeliver == 113
then
    $DestX = 2481.2122
    $DestY = -1345.3293
    $DestZ = 27.5971
    jump @Gosub03
end

if $CurrentHouseToDeliver == 114
then
    $DestX = 2481.5618
    $DestY = -1332.3475
    $DestZ = 28.2461
    jump @Gosub03
end

if $CurrentHouseToDeliver == 115
then
    $DestX = 2439.5891
    $DestY = -1357.2334
    $DestZ = 24.1008
    jump @Gosub03
end

if $CurrentHouseToDeliver == 116
then
    $DestX = 2439.6045
    $DestY = -1338.9287
    $DestZ = 24.1016
    jump @Gosub03
end

if $CurrentHouseToDeliver == 117
then
    $DestX = 2433.9319
    $DestY = -1320.6750
    $DestZ = 25.3234
    jump @Gosub03
end

if $CurrentHouseToDeliver == 118
then
    $DestX = 2434.3213
    $DestY = -1303.4650
    $DestZ = 24.9697
    jump @Gosub03
end

if $CurrentHouseToDeliver == 119
then
    $DestX = 2434.9868
    $DestY = -1289.4612
    $DestZ = 25.3479
    jump @Gosub03
end

if $CurrentHouseToDeliver == 120
then
    $DestX = 2433.6035
    $DestY = -1275.1392
    $DestZ = 24.7567
    jump @Gosub03
end

if $CurrentHouseToDeliver == 121
then
    $DestX = 2470.1057
    $DestY = -1295.6379
    $DestZ = 30.2332
    jump @Gosub03
end

if $CurrentHouseToDeliver == 122
then
    $DestX = 2469.0640
    $DestY = -1278.4202
    $DestZ = 30.3664
    jump @Gosub03
end

if $CurrentHouseToDeliver == 123
then
    $DestX = 2473.0417
    $DestY = -1238.4692
    $DestZ = 32.5695
    jump @Gosub03
end

if $CurrentHouseToDeliver == 124
then
    $DestX = 2492.0427
    $DestY = -1239.0109
    $DestZ = 37.9054
    jump @Gosub03
end

if $CurrentHouseToDeliver == 125
then
    $DestX = 2531.0508
    $DestY = -1227.9224
    $DestZ = 43.6562
    jump @Gosub03
end

if $CurrentHouseToDeliver == 126
then
    $DestX = 2550.6799
    $DestY = -1234.1431
    $DestZ = 49.0014
    jump @Gosub03
end

if $CurrentHouseToDeliver == 127
then
    $DestX = 2550.3550
    $DestY = -1197.2450
    $DestZ = 60.8252
    jump @Gosub03
end

if $CurrentHouseToDeliver == 128
then
    $DestX = 2587.0979
    $DestY = -1200.1024
    $DestZ = 59.2188
    jump @Gosub03
end

if $CurrentHouseToDeliver == 129
then
    $DestX = 2587.3193
    $DestY = -1202.9938
    $DestZ = 58.5760
    jump @Gosub03
end

if $CurrentHouseToDeliver == 130
then
    $DestX = 2587.3970
    $DestY = -1216.1495
    $DestZ = 55.1144
    jump @Gosub03
end

if $CurrentHouseToDeliver == 131
then
    $DestX = 2587.3757
    $DestY = -1233.3368
    $DestZ = 49.9621
    jump @Gosub03
end

if $CurrentHouseToDeliver == 132
then
    $DestX = 2600.0098
    $DestY = -1233.8723
    $DestZ = 49.8203
    jump @Gosub03
end

if $CurrentHouseToDeliver == 133
then
    $DestX = 2600.2214
    $DestY = -1224.9919
    $DestZ = 52.3446
    jump @Gosub03
end

if $CurrentHouseToDeliver == 134
then
    $DestX = 2599.8137
    $DestY = -1216.7931
    $DestZ = 54.9766
    jump @Gosub03
end

if $CurrentHouseToDeliver == 135
then
    $DestX = 2599.8596
    $DestY = -1207.8702
    $DestZ = 57.5078
    jump @Gosub03
end

if $CurrentHouseToDeliver == 136
then
    $DestX = 2614.4106
    $DestY = -1199.8434
    $DestZ = 60.7812
    jump @Gosub03
end

if $CurrentHouseToDeliver == 137
then
    $DestX = 2614.6091
    $DestY = -1207.6516
    $DestZ = 59.0703
    jump @Gosub03
end

if $CurrentHouseToDeliver == 138
then
    $DestX = 2614.6484
    $DestY = -1220.7228
    $DestZ = 55.1875
    jump @Gosub03
end

if $CurrentHouseToDeliver == 139
then
    $DestX = 2614.6626
    $DestY = -1233.5291
    $DestZ = 51.3828
    jump @Gosub03
end

if $CurrentHouseToDeliver == 140
then
    $DestX = 2662.4814
    $DestY = -1229.4418
    $DestZ = 58.1650
    jump @Gosub03
end

if $CurrentHouseToDeliver == 141
then
    $DestX = 2662.1455
    $DestY = -1216.5190
    $DestZ = 62.0743
    jump @Gosub03
end

if $CurrentHouseToDeliver == 142
then
    $DestX = 2662.6462
    $DestY = -1203.2023
    $DestZ = 65.5508
    jump @Gosub03
end

if $CurrentHouseToDeliver == 143
then
    $DestX = 2662.7998
    $DestY = -1207.4705
    $DestZ = 64.6471
    jump @Gosub03
end

if $CurrentHouseToDeliver == 144
then
    $DestX = 2683.0659
    $DestY = -1200.0662
    $DestZ = 66.7173
    jump @Gosub03
end

if $CurrentHouseToDeliver == 145
then
    $DestX = 2682.8948
    $DestY = -1207.6577
    $DestZ = 65.0105
    jump @Gosub03
end

if $CurrentHouseToDeliver == 146
then
    $DestX = 2682.8286
    $DestY = -1220.4016
    $DestZ = 61.1263
    jump @Gosub03
end

if $CurrentHouseToDeliver == 147
then
    $DestX = 2683.0266
    $DestY = -1233.7136
    $DestZ = 57.3316
    jump @Gosub03
end

if $CurrentHouseToDeliver == 148
then
    $DestX = 2683.4395
    $DestY = -1237.9806
    $DestZ = 56.0199
    jump @Gosub03
end

if $CurrentHouseToDeliver == 149
then
    $DestX = 2699.3879
    $DestY = -1238.5114
    $DestZ = 57.9977
    jump @Gosub03
end

if $CurrentHouseToDeliver == 150
then
    $DestX = 2699.4453
    $DestY = -1229.4684
    $DestZ = 60.6338
    jump @Gosub03
end

if $CurrentHouseToDeliver == 151
then
    $DestX = 2699.7161
    $DestY = -1216.3022
    $DestZ = 64.5612
    jump @Gosub03
end

if $CurrentHouseToDeliver == 152
then
    $DestX = 2699.0535
    $DestY = -1211.6323
    $DestZ = 65.9230
    jump @Gosub03
end

if $CurrentHouseToDeliver == 153
then
    $DestX = 2699.3337
    $DestY = -1203.1991
    $DestZ = 67.9997
    jump @Gosub03
end

if $CurrentHouseToDeliver == 154
then
    $DestX = 2755.8552
    $DestY = -1276.5186
    $DestZ = 56.5938
    jump @Gosub03
end

if $CurrentHouseToDeliver == 155
then
    $DestX = 2750.3896
    $DestY = -1238.5060
    $DestZ = 61.5245
    jump @Gosub03
end

if $CurrentHouseToDeliver == 156
then
    $DestX = 2750.3918
    $DestY = -1222.5182
    $DestZ = 64.6016
    jump @Gosub03
end

if $CurrentHouseToDeliver == 157
then
    $DestX = 2750.3916
    $DestY = -1205.5957
    $DestZ = 67.4844
    jump @Gosub03
end

if $CurrentHouseToDeliver == 158
then
    $DestX = 2756.3650
    $DestY = -1182.8099
    $DestZ = 69.4035
    jump @Gosub03
end

if $CurrentHouseToDeliver == 159
then
    $DestX = 2756.2949
    $DestY = -1302.6447
    $DestZ = 53.0938
    jump @Gosub03
end

if $CurrentHouseToDeliver == 160
then
    $DestX = 2713.0923
    $DestY = -1342.0131
    $DestZ = 46.4047
    jump @Gosub03
end

if $CurrentHouseToDeliver == 161
then
    $DestX = 2713.5874
    $DestY = -1377.6760
    $DestZ = 39.9665
    jump @Gosub03
end

if $CurrentHouseToDeliver == 162
then
    $DestX = 2713.6423
    $DestY = -1419.7378
    $DestZ = 32.3763
    jump @Gosub03
end

if $CurrentHouseToDeliver == 163
then
    $DestX = 2713.4294
    $DestY = -1444.5732
    $DestZ = 30.4513
    jump @Gosub03
end

if $CurrentHouseToDeliver == 164
then
    $DestX = 2713.1052
    $DestY = -1459.9574
    $DestZ = 30.5112
    jump @Gosub03
end

if $CurrentHouseToDeliver == 165
then
    $DestX = 2713.4829
    $DestY = -1468.9003
    $DestZ = 30.5636
    jump @Gosub03
end

if $CurrentHouseToDeliver == 166
then
    $DestX = 2751.8899
    $DestY = -1468.4241
    $DestZ = 30.4531
    jump @Gosub03
end

if $CurrentHouseToDeliver == 167
then
    $DestX = 2751.8899
    $DestY = -1438.3214
    $DestZ = 30.4531
    jump @Gosub03
end

if $CurrentHouseToDeliver == 168
then
    $DestX = 2846.1780
    $DestY = -1478.7593
    $DestZ = 10.9076
    jump @Gosub03
end

if $CurrentHouseToDeliver == 169
then
    $DestX = 2856.6875
    $DestY = -1479.1368
    $DestZ = 10.9275
    jump @Gosub03
end

if $CurrentHouseToDeliver == 170
then
    $DestX = 2861.6172
    $DestY = -1479.1161
    $DestZ = 10.9359
    jump @Gosub03
end

if $CurrentHouseToDeliver == 171
then
    $DestX = 2865.4517
    $DestY = -1465.7676
    $DestZ = 10.9528
    jump @Gosub03
end

if $CurrentHouseToDeliver == 172
then
    $DestX = 2865.4517
    $DestY = -1458.1156
    $DestZ = 10.9565
    jump @Gosub03
end

if $CurrentHouseToDeliver == 173
then
    $DestX = 2861.4458
    $DestY = -1440.1483
    $DestZ = 10.9375
    jump @Gosub03
end

if $CurrentHouseToDeliver == 174
then
    $DestX = 2851.8552
    $DestY = -1365.9310
    $DestZ = 14.1708
    jump @Gosub03
end

if $CurrentHouseToDeliver == 175
then
    $DestX = 2842.0818
    $DestY = -1334.7986
    $DestZ = 14.7421
    jump @Gosub03
end

if $CurrentHouseToDeliver == 176
then
    $DestX = 2807.8013
    $DestY = -1190.7556
    $DestZ = 25.3490
    jump @Gosub03
end

if $CurrentHouseToDeliver == 177
then
    $DestX = 2792.9065
    $DestY = -1087.8514
    $DestZ = 30.7188
    jump @Gosub03
end

if $CurrentHouseToDeliver == 178
then
    $DestX = 2512.7861
    $DestY = -1027.2767
    $DestZ = 70.0859
    jump @Gosub03
end

if $CurrentHouseToDeliver == 179
then
    $DestX = 2499.7383
    $DestY = -1065.6370
    $DestZ = 70.2359
    jump @Gosub03
end

if $CurrentHouseToDeliver == 180
then
    $DestX = 2479.2007
    $DestY = -1063.4893
    $DestZ = 66.8359
    jump @Gosub03
end

if $CurrentHouseToDeliver == 181
then
    $DestX = 2457.0798
    $DestY = -1054.4397
    $DestZ = 59.7422
    jump @Gosub03
end

if $CurrentHouseToDeliver == 182
then
    $DestX = 2462.2932
    $DestY = -1011.3963
    $DestZ = 60.1137
    jump @Gosub03
end

if $CurrentHouseToDeliver == 183
then
    $DestX = 2439.9773
    $DestY = -1010.8152
    $DestZ = 54.3438
    jump @Gosub03
end

if $CurrentHouseToDeliver == 184
then
    $DestX = 2389.5415
    $DestY = -1037.2690
    $DestZ = 53.5560
    jump @Gosub03
end

if $CurrentHouseToDeliver == 185
then
    $DestX = 2370.5774
    $DestY = -1034.8135
    $DestZ = 54.4106
    jump @Gosub03
end

if $CurrentHouseToDeliver == 186
then
    $DestX = 2355.4854
    $DestY = -1039.0428
    $DestZ = 54.1484
    jump @Gosub03
end

if $CurrentHouseToDeliver == 187
then
    $DestX = 2335.4385
    $DestY = -1045.1262
    $DestZ = 52.3582
    jump @Gosub03
end

if $CurrentHouseToDeliver == 188
then
    $DestX = 2319.1506
    $DestY = -1053.4348
    $DestZ = 52.3516
    jump @Gosub03
end

if $CurrentHouseToDeliver == 189
then
    $DestX = 2297.7642
    $DestY = -1053.4054
    $DestZ = 49.9340
    jump @Gosub03
end

if $CurrentHouseToDeliver == 190
then
    $DestX = 2279.0498
    $DestY = -1076.7502
    $DestZ = 47.6750
    jump @Gosub03
end

if $CurrentHouseToDeliver == 191
then
    $DestX = 2287.9192
    $DestY = -1080.2543
    $DestZ = 47.5678
    jump @Gosub03
end

if $CurrentHouseToDeliver == 192
then
    $DestX = 2249.3862
    $DestY = -1060.0837
    $DestZ = 55.9688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 193
then
    $DestX = 2259.4849
    $DestY = -1019.3801
    $DestZ = 59.2953
    jump @Gosub03
end

if $CurrentHouseToDeliver == 194
then
    $DestX = 2218.9250
    $DestY = -1031.2650
    $DestZ = 59.9622
    jump @Gosub03
end

if $CurrentHouseToDeliver == 195
then
    $DestX = 2208.8079
    $DestY = -1025.7765
    $DestZ = 60.8675
    jump @Gosub03
end

if $CurrentHouseToDeliver == 196
then
    $DestX = 2194.1799
    $DestY = -1000.1121
    $DestZ = 62.8642
    jump @Gosub03
end

if $CurrentHouseToDeliver == 197
then
    $DestX = 2201.6121
    $DestY = -1024.0048
    $DestZ = 61.4550
    jump @Gosub03
end

if $CurrentHouseToDeliver == 198
then
    $DestX = 2186.5815
    $DestY = -997.4500
    $DestZ = 66.4688
    jump @Gosub03
end

if $CurrentHouseToDeliver == 199
then
    $DestX = 2152.1697
    $DestY = -1014.3029
    $DestZ = 62.8040
    jump @Gosub03
end

if $CurrentHouseToDeliver == 200
then
    $DestX = 2140.0408
    $DestY = -1008.5107
    $DestZ = 61.9881
    jump @Gosub03
end

if $CurrentHouseToDeliver == 201
then
    $DestX = 2108.8198
    $DestY = -1000.7530
    $DestZ = 60.5078
    jump @Gosub03
end

if $CurrentHouseToDeliver == 202
then
    $DestX = 2154.0266
    $DestY = -979.8326
    $DestZ = 63.2934
    jump @Gosub03
end

if $CurrentHouseToDeliver == 203
then
    $DestX = 2142.7983
    $DestY = -978.2995
    $DestZ = 61.3793
    jump @Gosub03
end

if $CurrentHouseToDeliver == 204
then
    $DestX = 2131.9294
    $DestY = -974.0970
    $DestZ = 59.7856
    jump @Gosub03
end

if $CurrentHouseToDeliver == 205
then
    $DestX = 2122.0615
    $DestY = -970.5784
    $DestZ = 58.2074
    jump @Gosub03
end

if $CurrentHouseToDeliver == 206
then
    $DestX = 2090.9978
    $DestY = -972.5803
    $DestZ = 51.9275
    jump @Gosub03
end

if $CurrentHouseToDeliver == 207
then
    $DestX = 2073.6177
    $DestY = -965.2987
    $DestZ = 49.3016
    jump @Gosub03
end

if $CurrentHouseToDeliver == 208
then
    $DestX = 2051.0874
    $DestY = -954.6793
    $DestZ = 48.0343
    jump @Gosub03
end

if $CurrentHouseToDeliver == 209
then
    $DestX = 2044.5599
    $DestY = -991.0045
    $DestZ = 43.2007
    jump @Gosub03
end

if $CurrentHouseToDeliver == 210
then
    $DestX = 2015.3156
    $DestY = -977.7722
    $DestZ = 36.9531
    jump @Gosub03
end

if $CurrentHouseToDeliver == 211
then
    $DestX = 2007.2247
    $DestY = -984.7461
    $DestZ = 34.4609
    jump @Gosub03
end

if $CurrentHouseToDeliver == 212
then
    $DestX = 2000.0286
    $DestY = -991.8126
    $DestZ = 32.1314
    jump @Gosub03
end

if $CurrentHouseToDeliver == 213
then
    $DestX = 969.0953
    $DestY = -1381.9829
    $DestZ = 13.3438
    jump @Gosub03
end

if $CurrentHouseToDeliver == 214
then
    $DestX = 969.0953
    $DestY = -1357.8102
    $DestZ = 13.3502
    jump @Gosub03
end

if $CurrentHouseToDeliver == 215
then
    $DestX = 943.1176
    $DestY = -1418.1187
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 216
then
    $DestX = 982.5947
    $DestY = -1418.3412
    $DestZ = 13.4990
    jump @Gosub03
end

if $CurrentHouseToDeliver == 217
then
    $DestX = 1003.3542
    $DestY = -1418.3374
    $DestZ = 13.5858
    jump @Gosub03
end

if $CurrentHouseToDeliver == 218
then
    $DestX = 1022.5347
    $DestY = -1418.3374
    $DestZ = 13.6199
    jump @Gosub03
end

if $CurrentHouseToDeliver == 219
then
    $DestX = 943.1818
    $DestY = -1477.5394
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 220
then
    $DestX = 966.5157
    $DestY = -1500.7502
    $DestZ = 13.5473
    jump @Gosub03
end

if $CurrentHouseToDeliver == 221
then
    $DestX = 972.3729
    $DestY = -1479.6548
    $DestZ = 13.5562
    jump @Gosub03
end

if $CurrentHouseToDeliver == 222
then
    $DestX = 975.4522
    $DestY = -1479.6548
    $DestZ = 13.5780
    jump @Gosub03
end

if $CurrentHouseToDeliver == 223
then
    $DestX = 991.4893
    $DestY = -1479.8547
    $DestZ = 13.5559
    jump @Gosub03
end

if $CurrentHouseToDeliver == 224
then
    $DestX = 1010.8589
    $DestY = -1479.7339
    $DestZ = 13.5469
    jump @Gosub03
end

if $CurrentHouseToDeliver == 225
then
    $DestX = 1013.2115
    $DestY = -1500.7502
    $DestZ = 13.5473
    jump @Gosub03
end

if $CurrentHouseToDeliver == 226
then
    $DestX = 1004.2869
    $DestY = -1500.7502
    $DestZ = 13.5466
    jump @Gosub03
end

if $CurrentHouseToDeliver == 227
then
    $DestX = 985.3193
    $DestY = -1500.7502
    $DestZ = 13.5473
    jump @Gosub03
end

if $CurrentHouseToDeliver == 228
then
    $DestX = 976.2840
    $DestY = -1500.7502
    $DestZ = 13.5473
    jump @Gosub03
end

if $CurrentHouseToDeliver == 229
then
    $DestX = 940.8431
    $DestY = -1501.2202
    $DestZ = 13.5491
    jump @Gosub03
end

if $CurrentHouseToDeliver == 230
then
    $DestX = 903.3973
    $DestY = -1513.0094
    $DestZ = 14.3628
    jump @Gosub03
end

if $CurrentHouseToDeliver == 231
then
    $DestX = 849.8942
    $DestY = -1519.9139
    $DestZ = 14.3535
    jump @Gosub03
end

if $CurrentHouseToDeliver == 232
then
    $DestX = 822.4201
    $DestY = -1505.5183
    $DestZ = 14.3976
    jump @Gosub03
end

:GoBackTo_Gosub3
wait 0
jump @Gosub03
////////////////////////////////////////////////////////////////////////////------------------

:DeliveriesMade
wait 0 
$Delivered0 = 0
$Delivered1 = 0
$Delivered2 = 0
$Delivered3 = 0
$Delivered4 = 0
$Delivered5 = 0
$Delivered6 = 0
$Delivered7 = 0
$Delivered8 = 0
$Delivered9 = 0
$Delivered10 = 0


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                  ////////////   C H E C K  D E L I V E R I E S  L O C A T I O N S   /////////////////////////////////////////////********************************<<<<<<
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
:CheckDeliveryLocations 
wait 0


/////////////////////////////////////////////////////////////////     L O C 00
if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H0_X $H0_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and 
   $HoldingObjectAtMoment == -1
   not $Delivered0 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H0_X $H0_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and  
   not $HoldingObjectAtMoment == -1
   not $Delivered0 == 1
 then
    gosub @CheckLastDeliveredBoxExistence
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H0   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker0  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered0 = 1   
    $BoxesDelivered += 1
    wait 100
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
     end
  end  
end               
///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// 

/////////////////////////////////////////////////////////////////     L O C 01
if 
  00EC: actor $PLAYER_ACTOR sphere 0 near_point $H1_X $H1_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and   
   $HoldingObjectAtMoment == -1
   not $Delivered1 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H1_X $H1_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and   
   not $HoldingObjectAtMoment == -1
   not $Delivered1 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H1   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker1  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered1 = 1   
    $BoxesDelivered += 1
    wait 100
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 02
if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H2_X $H2_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered2 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H2_X $H2_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and   
   not $HoldingObjectAtMoment == -1
   not $Delivered2 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H2   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker2  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered2 = 1  
    $BoxesDelivered += 1
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 03
if 
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H3_X $H3_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered3 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H3_X $H3_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered3 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H3   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker3  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered3 = 1   
    $BoxesDelivered += 1 
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox     
    return
     end            
  end
end
/////////////////////////////////////////////////////////////////     L O C 04
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H4_X $H4_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
 if and    
   $HoldingObjectAtMoment == -1
   not $Delivered4 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H4_X $H4_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and  
   not $HoldingObjectAtMoment == -1
   not $Delivered4 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H4   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker4  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered4 = 1  
    $BoxesDelivered += 1
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 05
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point  $H5_X $H5_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered5 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point  $H5_X $H5_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered5 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H5   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker5  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered5 = 1  
    $BoxesDelivered += 1  
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 06
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H6_X $H6_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered6 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H6_X $H6_Y  radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered6 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H6   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker6  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered6 = 1  
    $BoxesDelivered += 1  
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 07
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point  $H7_X $H7_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered7 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point  $H7_X $H7_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered7 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H7   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker7  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered7 = 1  
    $BoxesDelivered += 1  
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 08
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H8_X $H8_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered8 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H8_X $H8_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered8 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H8   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker8  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered8 = 1   
    $BoxesDelivered += 1 
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 09
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H9_X $H9_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered9 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H9_X $H9_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered9 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H9   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker9  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered9 = 1   
    $BoxesDelivered += 1 
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end                 
  end
end
/////////////////////////////////////////////////////////////////     L O C 10
if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $Dest10_X $Dest10_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   $HoldingObjectAtMoment == -1
   not $Delivered10 == 1
 then
    03E5: show_text_box 'msg6' // " You need a box to deliver here!"
    wait 500
    03E5: show_text_box 'msg7' // "Go back to the back of the van and pick up a box!"
    return
end                       

if and
   00EC: actor $PLAYER_ACTOR sphere 0 near_point $H10_X $H10_Y radius 2.0 2.0  /////////////////////////HOUSE DELIVERY LOCATION 
 then
  if and    
   not $HoldingObjectAtMoment == -1
   not $Delivered10 == 1
 then
    04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 -1.0
    02CE: 11@ = ground_z_at 9@ 10@ 11@
    03BD: destroy_sphere $H10   //////////// DESTROY SPHERE
    0164: remove_marker $HouseFrontMarker10  ////////// DESTROY MARKER
    Player.CanMove($PLAYER_CHAR) = False
    0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time 600 //Play the "Put Down" animation 
    0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
    01BC: put_object $BoxToSpawn at 9@ 10@ 11@
    $PlayCarryingBoxAnim = 0 // Stop carrying box anim
    $AnimState = 0
    $HoldingObjectAtMoment = -1  ///Not holding any object anymore
    03E5: show_text_box 'msg5' 
    $Delivered10 = 1  
    $BoxesDelivered += 1  
    wait 100    
    $LastDeliveredBox = $BoxToSpawn
    gosub @TransformPermanentDroppedBox
    return
    end
  end
end

Player.CanMove($PLAYER_CHAR) = true

return

///////////////////////////////////////////////////////////////<<<<<<<<<<<<<<<<<<<<</////////////////////////////////////////////////////////////////////////////----------------<<<<<<<<<<<<<<<<<



////////////////////////////////////////////////////////////////////////////////////////////////////////////CAR MECHANISMS
:CarMechanisms
wait 0

if
    00DB: actor $PLAYER_ACTOR in_car $Truck
then

    // ========================================
    // TRUCK LIGHTS (Key 1 / Numpad 1 = 97)
    // ========================================
    if 
        0AB0: key_pressed 97 // 1
    then
        wait 50
        
        if
            $VehLightsOn == 0
        then 
            067F: set_car $Truck lights 2
            $VehLightsOn = 1
            0AD1: show_formatted_text_highpriority "~G~Veh lights on." time 400
        else 
            067F: set_car $Truck lights 0
            $VehLightsOn = 0
            0AD1: show_formatted_text_highpriority "~R~Veh lights off." time 400
        end
        
        wait 200
    end

    // ========================================
    // TRUCK ENGINE (Key 2 / Numpad 2 = 98)
    // ========================================
    if 
        0AB0: key_pressed 98 // 2
    then
        wait 50
        
        if
            $VehEngineOn == 0
        then 
            0918: set_car $Truck engine_on 1
            $VehEngineOn = 1
            0AD1: show_formatted_text_highpriority "~G~Engine on." time 400
        else 
            0918: set_car $Truck engine_on 0
            $VehEngineOn = 0
            0AD1: show_formatted_text_highpriority "~R~Engine off." time 400
        end
        
        wait 200
    end

end

return
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// CHANGE BACK OF THE VAN MENU PANEL STATE, TO SHOW HOW MANY BOXES WERE LOADED IN.
:ChangeBDVPanelState
wait 0 

if
    $LoadedBoxesIntoTruck == 0
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B0' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 1
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B01' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 2
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B02' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 3
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B03' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 4
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B04' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 5
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B05' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 6
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B06' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 7
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B07' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 8
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B08' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 9
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B09' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

if
    $LoadedBoxesIntoTruck == 10
then
    08DB: set_panel $BackOfTheVanMENU column 0 header 'MENU1' data 'B010' 'B2' 'B1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

return


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////*********************************************************************************************************************

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////////////****************************
// ------------------------------------------------------------------------------------------------------------------------
//                                                                     NEW: DROPPED BOX ARRAY LOGIC
// ------------------------------------------------------------------------------------------------------------------------

:SaveDroppedBox
wait 0
if
  $DropB0 == -1
then
  $DropB0 = $BoxToSpawn
  0188: $DropB0Marker = create_marker_above_object $DropB0
  return
end
if
  $DropB1 == -1
then
  $DropB1 = $BoxToSpawn
  0188: $DropB1Marker = create_marker_above_object $DropB1
  return
end
if
  $DropB2 == -1
then
  $DropB2 = $BoxToSpawn
  0188: $DropB2Marker = create_marker_above_object $DropB2
  return
end
if
  $DropB3 == -1
then
  $DropB3 = $BoxToSpawn
  0188: $DropB3Marker = create_marker_above_object $DropB3
  return
end
if
  $DropB4 == -1
then
  $DropB4 = $BoxToSpawn
  0188: $DropB4Marker = create_marker_above_object $DropB4
  return
end
if
  $DropB5 == -1
then
  $DropB5 = $BoxToSpawn
  0188: $DropB5Marker = create_marker_above_object $DropB5
  return
end
if
  $DropB6 == -1
then
  $DropB6 = $BoxToSpawn
  0188: $DropB6Marker = create_marker_above_object $DropB6
  return
end
if
  $DropB7 == -1
then
  $DropB7 = $BoxToSpawn
  0188: $DropB7Marker = create_marker_above_object $DropB7
  return
end
if
  $DropB8 == -1
then
  $DropB8 = $BoxToSpawn
  0188: $DropB8Marker = create_marker_above_object $DropB8
  return
end
if
  $DropB9 == -1
then
  $DropB9 = $BoxToSpawn
  0188: $DropB9Marker = create_marker_above_object $DropB9
  return
end
if
  $DropB10 == -1
then
  $DropB10 = $BoxToSpawn
  0188: $DropB10Marker = create_marker_above_object $DropB10
  return
end

return // Array is full, drops normally but won't be pickable
/////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
:PickupDroppedBox
wait 0

// ----------- CHECK BOX 0 -----------
if and
 $DropB0 > -1
 not $DropB0 == $CurrentBox 
    then
        01BB: store_object $DropB0 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB0
            $DropB0 = -1
            0164: disable_marker $DropB0Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 1 -----------
if and
 $DropB1 > -1
 not $DropB1 == $CurrentBox 
    then
        01BB: store_object $DropB1 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB1
            $DropB1 = -1
            0164: disable_marker $DropB1Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
    end
end
// ----------- CHECK BOX 2 -----------
if and
 $DropB2 > -1
 not $DropB2 == $CurrentBox 
    then
        01BB: store_object $DropB2 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB2
            $DropB2 = -1
            0164: disable_marker $DropB2Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 3 -----------
if and
 $DropB3 > -1
 not $DropB3 == $CurrentBox 
    then
        01BB: store_object $DropB3 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB3
            $DropB3 = -1
            0164: disable_marker $DropB3Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 4 -----------
if and
 $DropB4 > -1
 not $DropB4 == $CurrentBox 
    then
        01BB: store_object $DropB4 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB4
            $DropB4 = -1
            0164: disable_marker $DropB4Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 5 -----------
if and
 $DropB5 > -1
 not $DropB5 == $CurrentBox 
    then
        01BB: store_object $DropB5 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB5
            $DropB5 = -1
            0164: disable_marker $DropB5Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 6 -----------
if and
 $DropB6 > -1
 not $DropB6 == $CurrentBox 
    then
        01BB: store_object $DropB6 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB6
            $DropB6 = -1
            0164: disable_marker $DropB6Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 7 -----------
if and
 $DropB7 > -1
 not $DropB7 == $CurrentBox 
    then
        01BB: store_object $DropB7 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB7
            $DropB7 = -1
            0164: disable_marker $DropB7Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 8 -----------
if and
 $DropB8 > -1
 not $DropB8 == $CurrentBox 
    then
        01BB: store_object $DropB8 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB8
            $DropB8 = -1
            0164: disable_marker $DropB8Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 9 -----------
if and
 $DropB9 > -1
 not $DropB9 == $CurrentBox 
    then
        01BB: store_object $DropB9 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB9
            $DropB9 = -1
            0164: disable_marker $DropB9Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
// ----------- CHECK BOX 10 -----------
if and
 $DropB10 > -1
 not $DropB10 == $CurrentBox 
    then
        01BB: store_object $DropB10 position_to 12@ 13@ 14@
        if 00FE: actor $PLAYER_ACTOR sphere 0 near_point 12@ 13@ 14@ radius 1.5 1.5 1.5
        then
            $BoxToSpawn = $DropB10
            $DropB10 = -1
            0164: disable_marker $DropB10Marker
            0AD1: show_formatted_text_highpriority "~g~ BOX PICKED UP" time 1500
            jump @AttachPickedBox
        end
end
return
///////////////////////////////////////////////////////

///////////////////////////////////////////////////////
:AttachPickedBox
wait 0
0605: actor $PLAYER_ACTOR apply_animation "liftup" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time -1
wait 800
069B: attach_object $BoxToSpawn to_actor $PLAYER_ACTOR with_offset 0.0 0.60 0.30 rotation 0.0 0.0 0.0
$HoldingObjectAtMoment = 0
$PlayCarryingBoxAnim = 1
wait 500
0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time -1
wait 300
return
///////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////
:SashaSaveDeliveredDroppedBox
wait 0

if
    $DropB0 == -1
then
    $DropB0 = $CurrentBox
    return
end

if
    $DropB1 == -1
then
    $DropB1 = $CurrentBox
    return
end

if
    $DropB2 == -1
then
    $DropB2 = $CurrentBox
    return
end

if
    $DropB3 == -1
then
    $DropB3 = $CurrentBox
    return
end

if
    $DropB4 == -1
then
    $DropB4 = $CurrentBox
    return
end

if
    $DropB5 == -1
then
    $DropB5 = $CurrentBox
    return
end

if
    $DropB6 == -1
then
    $DropB6 = $CurrentBox
    return
end

if
    $DropB7 == -1
then
    $DropB7 = $CurrentBox
    return
end

if
    $DropB8 == -1
then
    $DropB8 = $CurrentBox
    return
end

if
    $DropB9 == -1
then
    $DropB9 = $CurrentBox
    return
end

if
    $DropB10 == -1
then
    $DropB10 = $CurrentBox
    return
end
//////////////////////////////////////////////////////////////////////////////////////////////




///////////////////////////////////////////////////////  Check if i delivered a box before delivering another one, to prevent multiple boxes to be persistent in the game.
:CheckLastDeliveredBoxExistence
wait 0 
if 
 $LastDeliveredBox > -1
 then
 0108: destroy_object $LastDeliveredBox
end
return
///////////////////////////////////////////////////////

//////////////////////////////////------------------------------------------------------GOSUB  CREATE BOXES MARKERS------------------------------
:CreateCheckpointOnDroppedBoxes
wait 0 

if
  $DropB0 > -1
then
  0188: $DropB0Marker = create_marker_above_object $DropB0
else
 if
  $DropB0 == -1
  then
    0164: disable_marker $DropB0Marker
  end
end
/////////////////////////
if
  $DropB1 > -1
then
  0188: $DropB1Marker = create_marker_above_object $DropB1
else
  if
    $DropB1 == -1
  then
    0164: disable_marker $DropB1Marker
  end
end
/////////////////////////
if
  $DropB2 > -1
then
  0188: $DropB2Marker = create_marker_above_object $DropB2
else
  if
    $DropB2 == -1
  then
    0164: disable_marker $DropB2Marker
  end
end
/////////////////////////
if
  $DropB3 > -1
then
  0188: $DropB3Marker = create_marker_above_object $DropB3
else
  if
    $DropB3 == -1
  then
    0164: disable_marker $DropB3Marker
  end
end
/////////////////////////
if
  $DropB4 > -1
then
  0188: $DropB4Marker = create_marker_above_object $DropB4
else
  if
    $DropB4 == -1
  then
    0164: disable_marker $DropB4Marker
  end
end
/////////////////////////
if
  $DropB5 > -1
then
  0188: $DropB5Marker = create_marker_above_object $DropB5
else
  if
    $DropB5 == -1
  then
    0164: disable_marker $DropB5Marker
  end
end
/////////////////////////
if
  $DropB6 > -1
then
  0188: $DropB6Marker = create_marker_above_object $DropB6
else
  if
    $DropB6 == -1
  then
    0164: disable_marker $DropB6Marker
  end
end
/////////////////////////
if
  $DropB7 > -1
then
  0188: $DropB7Marker = create_marker_above_object $DropB7
else
  if
    $DropB7 == -1
  then
    0164: disable_marker $DropB7Marker
  end
end
/////////////////////////
if
  $DropB8 > -1
then
  0188: $DropB8Marker = create_marker_above_object $DropB8
else
  if
    $DropB8 == -1
  then
    0164: disable_marker $DropB8Marker
  end
end
/////////////////////////
if
  $DropB9 > -1
then
  0188: $DropB9Marker = create_marker_above_object $DropB9
else
  if
    $DropB9 == -1
  then
    0164: disable_marker $DropB9Marker
  end
end
/////////////////////////
if
  $DropB10 > -1
then
  0188: $DropB10Marker = create_marker_above_object $DropB10
else
  if
    $DropB10 == -1
  then
    0164: disable_marker $DropB10Marker
  end
end

return

/////////////////////////////////////////////////////////////////////////////////----------------



:TransformPermanentDroppedBox ///////////////////////////////  IF ARRAY DROPPED OBJECT AS AN OBJECT, TRANSFORM IT INTO PERMANENT OBJECT, SO IT CAN BE DELETED
wait 0 

if
  $DropB0 > -1
then
  $ObjDropB0 = $DropB0
end

if
  $DropB1 > -1
then
  $ObjDropB1 = $DropB1
end

if
  $DropB2 > -1
then
  $ObjDropB2 = $DropB2
end

if
  $DropB3 > -1
then
  $ObjDropB3 = $DropB3
end

if
  $DropB4 > -1
then
  $ObjDropB4 = $DropB4
end

if
  $DropB5 > -1
then
  $ObjDropB5 = $DropB5
end

if
  $DropB6 > -1
then
  $ObjDropB6 = $DropB6
end

if
  $DropB7 > -1
then
  $ObjDropB7 = $DropB7
end

if
  $DropB8 > -1
then
  $ObjDropB8 = $DropB8
end

if
  $DropB9 > -1
then
  $ObjDropB9 = $DropB9
end

if
  $DropB10 > -1
then
  $ObjDropB10 = $DropB10
end
return

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////---------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////---------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////---------------------------------------------------









///////////////////////////////////////////////////////////////////////////******************************************************************************

///////////////////////////////////////////////////////////////////////////******************************************************************************
                                                                ////--------- S P A W N  N P C 'S  /  B O X E S  /////-------------
///////////////////////////////////////////////////////////////////////////******************************************************************************
:HowmanyDeliveriesToMake
wait 0 

///////////////////  CHECK IF SPAWNED BOXES ARE ENOUGH TO MAKE THE DELIVERIES.  If not, continue spawning boxes by restarting @SpawnBoxes1. d
if 
 $MaxDeliveriesToMake == 1
 then
   gosub @SpawnBox1
   $Actor1DidTask = 1         
   $EnableSashaFollowSystem = 1 
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 2
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   $Actor1DidTask = 1         
   $EnableSashaFollowSystem = 1 
   jump @SpawnStartNPC  
end 

if 
 $MaxDeliveriesToMake == 3
 then
   $Actor1DidTask = 1         
   $EnableSashaFollowSystem = 1 
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 4
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4   
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 5
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 6
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   gosub @SpawnBox6
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 7
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   gosub @SpawnBox6
   gosub @SpawnBox7
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 8
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   gosub @SpawnBox6
   gosub @SpawnBox7
   gosub @SpawnBox8
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 9
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   gosub @SpawnBox6
   gosub @SpawnBox7
   gosub @SpawnBox8
   gosub @SpawnBox9
   jump @SpawnStartNPC  
end 


if 
 $MaxDeliveriesToMake == 10
 then
   gosub @SpawnBox1
   gosub @SpawnBox2
   gosub @SpawnBox3
   gosub @SpawnBox4
   gosub @SpawnBox5
   gosub @SpawnBox6
   gosub @SpawnBox7
   gosub @SpawnBox8
   gosub @SpawnBox9
   gosub @SpawnBox10
   jump @SpawnStartNPC  
end 


////////////////////////////////////////////////////******************************  SPAWN BOXES / START CUTSCENE


:SpawnBox1
wait 0
///BOX 1
0107: $BoxToSpawn = create_object 1580 at 2465.0205 -1757.7489 13.5469  
02CE: 11@ = ground_z_at 2465.0205 -1757.7489 13.5469  
0682: detach_object $BoxToSpawn 2465.0205 -1757.7489 11@   collision_detection 1
01BC: put_object $BoxToSpawn at 2465.0205 -1757.7489 11@
gosub @SaveDroppedBox // <--- Saves object handle to an available Drop slot
$SpawnedBoxes += 1
return

:SpawnBox2
wait 0
///BOX 2
0107: $BoxToSpawn = create_object 1580 at 2465.0503 -1756.9054 13.5469
02CE: 11@ = ground_z_at 2465.0503 -1756.9054 13.5469
0682: detach_object $BoxToSpawn 2465.0503 -1756.9054 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2465.0503 -1756.9054 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return 

:SpawnBox3
wait 0
///BOX 3
0107: $BoxToSpawn = create_object 1580 at 2464.0530 -1756.7789 13.5469
02CE: 11@ = ground_z_at 2464.0530 -1756.7789 13.5469
0682: detach_object $BoxToSpawn 2464.0530 -1756.7789 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2464.0530 -1756.7789 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox4
wait 0
///BOX 4
0107: $BoxToSpawn = create_object 1580 at 2462.8691 -1756.8196 13.5469
02CE: 11@ = ground_z_at 2462.8691 -1756.8196 13.5469
0682: detach_object $BoxToSpawn 2462.8691 -1756.8196 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2462.8691 -1756.8196 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox5
wait 0
///BOX 5
0107: $BoxToSpawn = create_object 1580 at 2463.0818 -1755.6279 13.5469
02CE: 11@ = ground_z_at 2463.0818 -1755.6279 13.5469
0682: detach_object $BoxToSpawn 2463.0818 -1755.6279 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2463.0818 -1755.6279 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox6
wait 0
///BOX 6
0107: $BoxToSpawn = create_object 1580 at 2462.8809 -1754.1345 13.5469
02CE: 11@ = ground_z_at 2462.8809 -1754.1345 13.5469
0682: detach_object $BoxToSpawn 2462.8809 -1754.1345 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2462.8809 -1754.1345 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox7
wait 0
///BOX 7
0107: $BoxToSpawn = create_object 1580 at 2462.0181 -1755.4993 13.5469
02CE: 11@ = ground_z_at 2462.0181 -1755.4993 13.5469
0682: detach_object $BoxToSpawn 2462.0181 -1755.4993 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2462.0181 -1755.4993 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
wait 5

:SpawnBox8
wait 0
///BOX 8
0107: $BoxToSpawn = create_object 1580 at 2461.3689 -1754.3730 13.5469
02CE: 11@ = ground_z_at 2461.3689 -1754.3730 13.5469
0682: detach_object $BoxToSpawn 2461.3689 -1754.3730 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2461.3689 -1754.3730 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox9
wait 0
///BOX 9
0107: $BoxToSpawn = create_object 1580 at 2460.4846 -1756.2113 13.5469
02CE: 11@ = ground_z_at 2460.4846 -1756.2113 13.5469
0682: detach_object $BoxToSpawn 2460.4846 -1756.2113 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2460.4846 -1756.2113 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

:SpawnBox10
wait 0
///BOX 10
0107: $BoxToSpawn = create_object 1580 at 2459.4285 -1754.1760 13.5469
02CE: 11@ = ground_z_at 2459.4285 -1754.1760 13.5469
0682: detach_object $BoxToSpawn 2459.4285 -1754.1760 11@ collision_detection 1
01BC: put_object $BoxToSpawn at 2459.4285 -1754.1760 11@
gosub @SaveDroppedBox
$SpawnedBoxes += 1
return

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
:SpawnStartNPC
WAIT 0

$EnableSashaFollowSystem = 0
01B4: set_player $PLAYER_CHAR can_move 0
0826: enable_hud 0
0581: enable_radar 0

// Fade OUT first
016A: fade 0 time 1000
wait 1200
00BA: show_text_styled GXT 'MISS1' time 6000 style 2
// Move player
00A1: put_actor $PLAYER_ACTOR at 2468.7288 -1757.6095 13.5469

// Create NPC
009A: $Actor1 = create_actor_pedtype 4 model 11 at 2467.1892 -1753.2563 13.5469
0173: set_actor $Actor1 Z_angle_to 174.14

// Let GTA finish creating the ped
wait 600

// Set camera while still black
015F: set_camera_position 2459.6597 -1757.5675 13.600 rotation 0.0 0.0 0.0
0160: set_camera_point_at 2467.1892 -1753.2563 13.5469 switchstyle 2

// Make CJ look at NPC
05BF: AS_actor $PLAYER_ACTOR look_at_actor $Actor1 10000 ms
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0
06BA: AS_actor $PLAYER_ACTOR turn_to_and_look_at 9@ 10@ 11@

// Fade IN
016A: fade 1 time 1500
wait 1600

///////////
016A: fade 1 time 450
wait 300

jump @SelectDialogToShow

:SelectDialogToShow
wait 0

////////////////////////
if
 $MaxDeliveriesToMake == 1
then
 jump @Actor1Dialog01
end

////////////////////////
if
 $MaxDeliveriesToMake == 2
then
 jump @Actor1Dialog02
end

////////////////////////
if
 $MaxDeliveriesToMake == 3
then
 jump @Actor1Dialog03
end


////////////////////////
if or
 $MaxDeliveriesToMake == 4
 $MaxDeliveriesToMake > 4
then
 wait 200
 jump @Actor1Dialog04
end

jump @SelectDialogToShow

///////////////////////////////////////////////////////////////////////////////////////////// D I A L O G  0 1   //////////////////////////////////////////////////
:Actor1Dialog01
wait 0
0AD1: show_formatted_text_highpriority "~w~ Just deliver it for me. I hope you don't scratch your nails!" time 2900
wait 3000
02EB: restore_camera_with_jumpcut
   0826: enable_hud 1
   0581: enable_radar 1
   04C4: store_coords_to 7@ 8@ 9@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
   06BA: AS_actor $Actor1 turn_to_and_look_at 7@ 8@ 9@
   0ACA: show_text_box "~g~Press ~g~G to pick up a box. Press ~y~F~g~ to load the box into the truck."
   wait 700
   01B4: set_player $PLAYER_CHAR can_move 1   
   jump @StartMission2  ///// To choose the locations to make the deliveries
///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////// D I A L O G  0 2  //////////////////////////////////////////////////
:Actor1Dialog02
wait 0
0AD1: show_formatted_text_highpriority "~w~ Here's the stuff. You know what to do. Or i think so!" time 2900
wait 3000
04C4: store_coords_to 7@ 8@ 9@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
06BA: AS_actor $Actor1 turn_to_and_look_at 7@ 8@ 9@
02EB: restore_camera_with_jumpcut
   0826: enable_hud 1
   0581: enable_radar 1
   0ACA: show_text_box "~g~Press ~g~G to pick up a box. Press ~y~F~y~ to load the box into the truck."
   01B4: set_player $PLAYER_CHAR can_move 1
   jump @StartMission2  ///// To choose the locations to make the deliveries
///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////// D I A L O G  0 3  //////////////////////////////////////////////////
:Actor1Dialog03
wait 0
0AD1: show_formatted_text_highpriority "~w~ I believe you understand how serious this is it. Don't be a bastard and stop wasting my time!" time 3000
wait 3000
04C4: store_coords_to 7@ 8@ 9@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
06BA: AS_actor $Actor1 turn_to_and_look_at 7@ 8@ 9@
02EB: restore_camera_with_jumpcut
   0826: enable_hud 1
   0581: enable_radar 1
   01B4: set_player $PLAYER_CHAR can_move 1  
   0ACA: show_text_box "~g~Press ~r~G to pick up a box. Then, press ~y~F~y~ to load the box into the truck."
   01B4: set_player $PLAYER_CHAR can_move 1
   jump @StartMission2  ///// To choose the locations to make the deliveries
///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////// D I A L O G  0 4   //////////////////////////////////////////////////
:Actor1Dialog04
wait 0
$EnableSashaFollowSystem1 = 0  ///////Deactivate follow menu
0AD1: show_formatted_text_highpriority "~w~ I need you to deliver it for me. Ask no questions!" time 2900
03E5: show_text_box "SKP1"
gosub @WaitForDialogSkip1
wait 1600
0AD1: show_formatted_text_highpriority "~w~ And please: don't be a fucking idiot to attract all the heat to yourself!" time 2950
03E5: show_text_box "SKP1"
gosub @WaitForDialogSkip1

:StartWaitActor1
wait 0
//////// Is NPC at loc yet?
  03E5: show_text_box "SKP1"
   
   0AD1: show_formatted_text_highpriority "~w~ Pick up a box by pressing G. Then, put it into the truck, by going in the back of the vehicle and pressing F" time 5000
   
   gosub @WaitForDialogSkip2
   
   wait 3200
   03E5: show_text_box "SKP1"
   0AD1: show_formatted_text_highpriority "~w~ If you shut up, i could help you to load the truck up." time 4000
   gosub @WaitForDialogSkip2
   :StartContinue1
   wait 0
   02EB: restore_camera_with_jumpcut
   0826: enable_hud 1
   0581: enable_radar 1
   01B4: set_player $PLAYER_CHAR can_move 1
   jump @NPCLookForBox
   
///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////IF I PRESS L SHIFT, SKIP DIALOGS ABOVE. 

:WaitForDialogSkip1
wait 0 
if
 0AB0: key_pressed 160 // Shift
 then
  03E5: show_text_box "M13"  
  jump @StartWaitActor1
end  
return
////-------------------
:WaitForDialogSkip2
wait 0 
if
 0AB0: key_pressed 160 // Shift
 then
  03E5: show_text_box "M13"  
  jump @StartContinue1
end  
return
/////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



/////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                                                                // N P C -  $Actor1    P I C K  B O X  ......... F O L L O W 

////  ////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:NPCLookForBox
wait 0
$CurrentBox = -1

// Checking DropB0 through DropB10 safely
if $DropB0 > -1 
then $CurrentBox = $DropB0 
end

if $DropB1 > -1 
then $CurrentBox = $DropB1 
end

if $DropB2 > -1 
then $CurrentBox = $DropB2 
end

if $DropB3 > -1 
then $CurrentBox = $DropB3 
end

if $DropB4 > -1 
then $CurrentBox = $DropB4 
end

if $DropB5 > -1 
then $CurrentBox = $DropB5 
end

if $DropB6 > -1 
then $CurrentBox = $DropB6 
end

if $DropB7 > -1 
then $CurrentBox = $DropB7 
end

if $DropB8 > -1 
then $CurrentBox = $DropB8 
end

if $DropB9 > -1 
then $CurrentBox = $DropB9 
end

if $DropB10 > -1 
then $CurrentBox = $DropB10 
end

if $CurrentBox > -1
then
    jump @NPCGoToBox
else
    jump @Actor1GivingUpLoadingBoxes
end

////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

:NPCGoToBox
wait 0
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu
gosub @PressGToDropBox
gosub @PressGToPickupBox
gosub @OpenBackOfTheVanMenu
gosub @CJCarryBoxAnimCheck 

///////////////////////////////// CHECK DISTANCE BETWEEN $Actor1 AND $Truck   //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0
wait 0
0509: 2@ = distance_between_XY 6@ 7@ and_XY 9@ 10@ 

if
  2@ > 15.0
then
    // Truck is TOO FAR - warn or fail
    if
       not $StopCloserWarn == 1
    then
        0AD1: show_formatted_text_highpriority "~w~Where are you going with this truck? If you don't come back, it's over!" time 2500
        $StopCloserWarn = 1
        0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
        jump @NPCGoToBox
    end
 end
 ///////////////////////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

///////////////////////////////////////////  IF $Actor1 IS CLOSE TO THE TRUCK. IF IT'S, SHE WILL HELP TO LOAD THE TRUCK UP. 
if
   00ED: actor $Actor1 sphere 1 near_point 9@ 10@ radius 15.0 15.0 on_foot  //// Near truck actor1
then
    jump @Actor1FindRandomBox
else
   0AD1: show_formatted_text_highpriority "~w~ I could've helped you. But as you're a fucking idiot, the truck is too far away! Don't even try to back it up. I'm done! Do it by yourself now!" time 5000 
   wait 5000   
   $Actor1DidTask = 1
end


/////   FIND A RANDOM BOX TO PICK UP AND TAKE TO THE TRUCK
:Actor1FindRandomBox
wait 0 
//////*********************************************************************************************************
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu
gosub @PressGToDropBox
gosub @PressGToPickupBox


gosub @CJCarryBoxAnimCheck 

///////////////////////////////// CHECK DISTANCE BETWEEN $Actor1 AND $Truck   //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0

///////////////////////////////////////////
0509: 2@ = distance_between_XY 6@ 7@ and_XY 9@ 10@ 

if
  2@ > 15.0
then
    0AD1: show_formatted_text_highpriority "~w~Stop the truck right now! Do not move one inch! Or centimeter. Whatever..." time 2500
    $StopCloserWarn = 1
else
    $StopCloserWarn = 0
end


 ///////////////////////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//////*********************************************************************************************************

01BB: store_object $CurrentBox position_to 0@ 1@ 2@
wait 5
05D3: AS_actor $Actor1 goto_point 0@ 1@ 2@ mode 4 time -1

if
    051A: actor $Actor1 damaged_by_actor $PLAYER_ACTOR
then
    0AD1: show_formatted_text_highpriority "~r~Hey! Watch it!" time 1500
    jump @Actor1FindRandomBox
else
   if
  00EC: actor $Actor1 sphere 0 near_point 0@ 1@ radius 1.0 1.0
 then
  $SashaDeliverTimerStarted = 0
  jump @WaitNPCAtBox   
 end
end

jf @Actor1FindRandomBox


///-------------------------------------  
:WaitNPCAtBox   ///// Wait $Actor1 to reach back chosen box to pick up
wait 0

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   
0812: AS_actor $Actor1 perform_animation "liftup" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 750
wait 750
0687: clear_actor $Actor1 task

wait 200

069B: attach_object $CurrentBox to_actor $Actor1 with_offset 0.0 0.60 0.30 rotation 0.0 0.0 0.0
wait 50
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
wait 0
05D3: AS_actor $Actor1 goto_point 6@ 7@ 8@ mode 4 time -1      ///// GOTO TRUCK AND PUT BOX INSIDE


timera = 0 // Reset internal timer
$SashaDeliverTimerStarted = 0
///////////////////////////////----------------------------------------------------------------


/////////////////////////
:WaitNPCAtTruck
wait 0
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu
gosub @PressGToDropBox
gosub @PressGToPickupBox
gosub @OpenBackOfTheVanMenu
gosub @CJCarryBoxAnimCheck 
///////////////////////////

0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0
$Actor1LoadingBox = 1
// ========================================
// TIMER SYSTEM - Reissue task if stuck
// ========================================

// Start timer on first entry (only once)
if
    $SashaDeliverTimerStarted == 0
then
    $SashaDeliverTimerStart = timera
    $SashaDeliverTimerStarted = 1
end

// Check if 5 seconds passed without reaching destination
if
    timera > 5000
then
    wait 0 
    05D3: AS_actor $Actor1 goto_point 6@ 7@ 8@ mode 4 time -1 
    timera = 0
end
    

///////////////////////////////// CHECK DISTANCE BETWEEN $Actor1 AND $Truck   //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0509: 2@ = distance_between_XY 6@ 7@ and_XY 9@ 10@ 

///////////////////////////////////////////
if
  2@ >= 15.0
then
    0AD1: show_formatted_text_highpriority "~w~Stop the truck right now! Do not move one inch! Or centimeter. Whatever..." time 2500
    $StopCloserWarn = 1
    wait 2000
    jump @WaitNPCAtTruck
else
    $StopCloserWarn = 0
end 
 
    
if
  00EC: actor $Actor1 sphere 0 near_point 6@ 7@ radius 1.1 1.1 
 then
   jump @NPCPutBoxInTruck
 else
   0605: actor $Actor1 apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1000
end


jump @WaitNPCAtTruck
/////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 





















////////////////////////////////////////////////////
:NPCPutBoxInTruck
wait 0
0605: actor $Actor1 apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu
gosub @PressGToDropBox
gosub @PressGToPickupBox
gosub @OpenBackOfTheVanMenu
gosub @CJCarryBoxAnimCheck 

///////////////////////////////// CHECK DISTANCE BETWEEN $Actor1 AND $Truck   //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0

if
  $TruckDoorsOpen == 1
 then  
     $ChooseActor1RandomTalkToLoadBox = 1
     jump @OneLessBoxDialog
 else
     08A6: set_car $Truck door $TrunkID rotation_to 1.0
     $TruckDoorsOpen = 1
     $ChooseActor1RandomTalkToLoadBox = 1
     wait 350
     jump @OneLessBoxDialog
end

/////////////////////////////////////////////////---------------------------------------------------------


////////////////////////////////////////////////////
:OneLessBoxDialog
wait 0 
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu
gosub @OpenBackOfTheVanMenu

gosub @CJCarryBoxAnimCheck 
//////////////////////////////////////////////////// CHECK CARRYING BOX ANIM

if or
 $ChooseActor1RandomTalkToLoadBox == 0
 $ChooseActor1RandomTalkToLoadBox == 1
then
0099: $ChooseActor1RandomTalkToLoadBox = random_int_in_ranges_0_to_7
 if
  $ChooseActor1RandomTalkToLoadBox == 1
  then
   0AD1: show_formatted_text_highpriority "~w~ One less box to go." time 1500
end
  
  if
  $ChooseActor1RandomTalkToLoadBox == 2
  then
   0AD1: show_formatted_text_highpriority "~w~ How long are you going to watch me work?" time 1500
end 

 if
  $ChooseActor1RandomTalkToLoadBox == 3
  then
   0AD1: show_formatted_text_highpriority "~w~ I can't believe you don't feel just a little bit ashamed to be there, doing absolute nothing!" time 1500
end 

 if
  $ChooseActor1RandomTalkToLoadBox == 4
  then
   0AD1: show_formatted_text_highpriority "~w~ Won't you help me?" time 1500
end 

 if or
  $ChooseActor1RandomTalkToLoadBox == 5
  $ChooseActor1RandomTalkToLoadBox == 7
  then
   0AD1: show_formatted_text_highpriority "~w~ How long do you think i can keep up with this?" time 1500
end 

 if and
  $ChooseActor1RandomTalkToLoadBox == 6
  not $LoadedBoxesIntoTruck == $MaxDeliveriesToMake
 then
   0AD1: show_formatted_text_highpriority "~w~ I really don't know how to show you what a shame you're!" time 1500
  end 

 if and
  $ChooseActor1RandomTalkToLoadBox == 6
  $LoadedBoxesIntoTruck == $MaxDeliveriesToMake
 then
   0AD1: show_formatted_text_highpriority "~w~ Man, look at you! I did all the heavy work. Why do you behave like Juniao? Why you don't do anything else than watching me work?" time 1500
  end 
end 


$ChooseActor1RandomTalkToLoadBox_RANDOMRANGE = 0  ////RESET VAR to choose a random dialog while $Actor1 puts a box into the $Truck



//////////////////-------------------------------
$LoadedBoxesIntoTruck += 1 ///// Add 1 box to the $Truck


0682: detach_object $CurrentBox 0.0 0.0 0.0 collision_detection 0  // FIX: Detach the object from her hand before it gets destroyed, and clear her animation!


// Only close doors if the player hasn't quickly reopened the menu
if $BDV_MENU_OPEN == 0
then
    08A6: set_car $Truck door $TrunkID rotation_to 0.0
    $TruckDoorsOpen = 0
end

// FIX: Removed the "else" block so this logic always runs properly
$Actor1LoadingBox = 0
jump @CheckBoxInTruckToDelete



/////////////////////////////////////
:CheckBoxInTruckToDelete
wait 0

///////////***************-----------  ////// DELETE BOX PUT INTO TRUCK BY $Actor1 NPC

// ----------- BOX 0 -----------
if
    $CurrentBox == $DropB0
then
    if
        03CA: object $DropB0 exists
    then
        0108: destroy_object $DropB0
        wait 50
        $DropB0 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB0Marker
    end
end

// ----------- BOX 1 -----------
if
    $CurrentBox == $DropB1
then
    if
        03CA: object $DropB1 exists
    then
        0108: destroy_object $DropB1
        wait 50
        $DropB1 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB1Marker
    end
end

// ----------- BOX 2 -----------
if
    $CurrentBox == $DropB2
then
    if
        03CA: object $DropB2 exists
    then
        0108: destroy_object $DropB2
        wait 50
        $DropB2 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB2Marker
    end
end

// ----------- BOX 3 -----------
if
    $CurrentBox == $DropB3
then
    if
        03CA: object $DropB3 exists
    then
        0108: destroy_object $DropB3
        wait 50
        $DropB3 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB3Marker
    end
end

// ----------- BOX 4 -----------
if
    $CurrentBox == $DropB4
then
    if
        03CA: object $DropB4 exists
    then
        0108: destroy_object $DropB4
        wait 50
        $DropB4 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB4Marker
    end
end

// ----------- BOX 5 -----------
if
    $CurrentBox == $DropB5
then
    if
        03CA: object $DropB5 exists
    then
        0108: destroy_object $DropB5
        wait 50
        $DropB5 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB5Marker
    end
end

// ----------- BOX 6 -----------
if
    $CurrentBox == $DropB6
then
    if
        03CA: object $DropB6 exists
    then
        0108: destroy_object $DropB6
        wait 50
        $DropB6 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB6Marker
    end
end

// ----------- BOX 7 -----------
if
    $CurrentBox == $DropB7
then
    if
        03CA: object $DropB7 exists
    then
        0108: destroy_object $DropB7
        wait 50
        $DropB7 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB7Marker
    end
end

// ----------- BOX 8 -----------
if
    $CurrentBox == $DropB8
then
    if
        03CA: object $DropB8 exists
    then
        0108: destroy_object $DropB8
        wait 50
        $DropB8 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB8Marker
    end
end

// ----------- BOX 9 -----------
if
    $CurrentBox == $DropB9
then
    if
        03CA: object $DropB9 exists
    then
        0108: destroy_object $DropB9
        wait 50
        $DropB9 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB9Marker
    end
end

// ----------- BOX 10 -----------
if
    $CurrentBox == $DropB10
then
    if
        03CA: object $DropB10 exists
    then
        0108: destroy_object $DropB10
        wait 50
        $DropB10 = -1
        $CurrentBox = -1
        0164: remove_marker $DropB10Marker
    end
end
//------------------------------------------------------------------------
$SashaDeliverTimerStarted = 0 
jump @NPCLookForBox
//////////////////////////////////////////////////////


/////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:Actor1GivingUpLoadingBoxes
wait 0 

//////*********************************************************************************************************
///////////////////////////////////////   UNIVERSAL 'G' KEY LOGIC ( DROP)
gosub @PressGToDropBox
//////////////////////////////////  PRESS G (PICKUP)
gosub @PressGToPickupBox
/////////////////////////////////
gosub @CarMechanisms   /// Car engine and lights
gosub @MissionFailedCheck1  // Check car exploded or player dead

gosub @OpenBackOfTheVanMenu

gosub @CJCarryBoxAnimCheck 
//////////////////////////////////////////////////// CHECK CARRYING BOX ANIM
//////*********************************************************************************************************

0AD1: show_formatted_text_highpriority "~w~ Here we go, tough guy. But i know, even my mom could drive that bathub!" time 2000  
wait 1800
$Actor1DidTask = 1
$EnableSashaFollowSystem = 1
jump @StartMission2  ///// To choose the locations to make the deliveries

/////////////////////////////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



//////***********************

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
:PressGToDropBox
wait 0 
if and
  0AB0: key_pressed 71 // G
  044B: actor $PLAYER_ACTOR on_foot
then
    if 
      not $HoldingObjectAtMoment == -1 
     then
        $DroppingBox = 1
        04C4: store_coords_to 9@ 10@ 11@ from_actor $PLAYER_ACTOR with_offset 0.0 0.5 0.5
        02CE: 11@ = ground_z_at 9@ 10@ 11@          
        0812: AS_actor $PLAYER_ACTOR perform_animation "putdwn05" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 250 
        wait 200
        0682: detach_object $BoxToSpawn 9@ 10@ 11@ collision_detection 1
        01BC: put_object $BoxToSpawn at 9@ 10@ 11@
         
        gosub @SaveDroppedBox // <--- Saves object handle to an available Drop slot
        
        wait 100
        $BoxToSpawn = -1 
        $HoldingObjectAtMoment = -1 
        $PlayCarryingBoxAnim = 0
        $DroppingBox = 0
    end
end

return

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

:PressGToPickupBox
wait  0
if and
  0AB0: key_pressed 71 // G
  044B: actor $PLAYER_ACTOR on_foot
then
   if and
    $DroppingBox == 0
    $HoldingObjectAtMoment == -1
    then
        wait 100
        gosub @PickupDroppedBox // <--- Checks slots for nearby boxes and picks it up
   end
end

return

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

:CanceledMission
wait 0

if 
  0AB0: key_pressed 80 //P
then
 jump @MissionFailed1
end
return
/////////////////////////


///////////////////////////////////////PRESS F IN THE BACK OF THE VAN: OPEN MENU TO PUT BOXES
:OpenBackOfTheVanMenu
wait 0

0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0

// 3. OPEN THE MENU
if
  00DB: not actor $PLAYER_ACTOR in_car $Truck
  00EC: actor $PLAYER_ACTOR sphere 0 near_point 6@ 7@ radius 2.0 2.0
  then
 if
   0AB0: key_pressed 70 // F key  
   then
      wait 40
    // Use GOSUB for menu
    jump @BackOfTheVanMENU
  end
end

return
   
////////////////////////////////////////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                //// SASHA DIALOG MENU
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////SASHA DIALOG MENU ///--------OPEN MENU TO ORDER SASHA TO DELIVER BOXES BY HERSELF///

:SashaDialogMENU /////////
wait 0 
Player.CanMove($PLAYER_CHAR) = False
//////////////////////////////////////////////////////////////////////////////////CREATE THE BACK OF THE VAN MENU TO CHOOSE A BOX TO DELIVER
// FIX: Changed "columns 2" to "columns 1"
08D4: $SashaDialogMENU = create_panel_with_title 'DUMMY' position 200.0 330.0 width 140.0 columns 1 interactive 1 background 1 alignment 0

// FIX: Set up panel text and rows ONCE before the loop
if
    $Actor1FollowPlayer == 0
then
    08DB: set_panel $SashaDialogMENU column 0 header 'SSHA0' data 'SSHA1' 'SSHA3' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
else
    08DB: set_panel $SashaDialogMENU column 0 header 'SSHA0' data 'SSHA2' 'SSHA3' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

08D9: set_panel $SashaDialogMENU row 0 enable 1
if and
  $Actor1FollowPlayer == 1
  $EnableSashaFollowSystem = 1
then
   08D9: set_panel $SashaDialogMENU row 1 enable 1
else
   08D9: set_panel $SashaDialogMENU row 1 enable 0
end
08D9: set_panel $SashaDialogMENU row 2 enable 1

$SashaDialogMENU_Open = 1
$SelectedSashaMenuRow = 0 // 

:SashaDialogMENU2
wait 0 

08D8: $SelectedSashaMenuRow = panel $SashaDialogMENU selected_row

if
0AB0: key_pressed 8  ///backspace
then
    $PlayCarryingBoxAnim = 0
    jump @CloseSashaDialogMenuPanel 
end
/////////////////////////////

/////////////////////////CHANGE PANEL STATE FROM FOLLOW TO STOP FOLLOWING AND VICE-VERSA
if
    $Actor1FollowPlayer == 0
then
    08DB: set_panel $SashaDialogMENU column 0 header 'SSHA0' data 'SSHA1' 'SSHA3' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end
///------------------

if
    $Actor1FollowPlayer == 1
then
    08DB: set_panel $SashaDialogMENU column 0 header 'SSHA0' data 'SSHA2' 'SSHA3' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
end

//////////////////////////////////

08D8: $SelectedSashaMenuRow = panel $SashaDialogMENU selected_row


 //////////////////////////////////////////////////////// ORDER: SASHA FOLLOWS
if or    
    0AB0: key_pressed 13 // Enter
    0AB0: key_pressed 160 // Shift
then
    if $SelectedSashaMenuRow == 0 
    then
        if $Actor1FollowPlayer == 0   
        then
           0687: clear_actor $Actor1 task
           wait 50
           $Actor1FollowPlayer = 1  
           $Actor1InCarWithPlayer = 0
           0AD1: show_formatted_text_highpriority "~g~I'll come with you!" time 1500 
           jump @CloseSashaDialogMenuPanel 
           
        else
            $Actor1FollowPlayer = 0  
            $Actor1InCarWithPlayer = 0
            0AD1: show_formatted_text_highpriority "~r~I'll stay here." time 1500
            jump @CloseSashaDialogMenuPanel
             
        end
    end

    if $SelectedSashaMenuRow == 1
    then
        if $Actor1DidTask == 1
        then
            0687: clear_actor $Actor1 task
            wait 50
            $MakeSashaDeliverBox1 = 1
            jump @CloseSashaDialogMenuPanel
        end      
    end
end   

jump @SashaDialogMENU2

return

//////////////////////////////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<<</****        
:ClosestDelLoc
wait 0
04C4: store_coords_to 11@ 12@ 13@ from_actor $Actor1 with_offset 0.0 0.0 0.0
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0

if 
    00EC: actor $Actor1 sphere 0 near_point $H0_X $H0_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H0_X
    $HouseForSashaToDeliver_Y = $H0_Y
    $HouseForSashaToDeliver_Z = $H0_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H0
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker0  
    $LocToResetAfterSashaDeliverBox = 0
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~It's a joke, right?" time 2000 
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H1_X $H1_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H1_X
    $HouseForSashaToDeliver_Y = $H1_Y
    $HouseForSashaToDeliver_Z = $H1_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H1
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker1  
    $LocToResetAfterSashaDeliverBox = 1
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~Naa, don't tell me you're sending me to deliver it instead??" time 2000
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H2_X $H2_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H2_X
    $HouseForSashaToDeliver_Y = $H2_Y
    $HouseForSashaToDeliver_Z = $H2_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H2
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker2   
    $LocToResetAfterSashaDeliverBox = 2
    0AD1: show_formatted_text_highpriority "~w~Naa, don't tell me you're sending me to deliver it instead??" time 2000
    wait 2000
    $MakeSashaDeliverBox1 = 1
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H3_X $H3_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H3_X
    $HouseForSashaToDeliver_Y = $H3_Y
    $HouseForSashaToDeliver_Z = $H3_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H3
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker3    
    $LocToResetAfterSashaDeliverBox = 3
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~Naa, don't tell me you're sending me to deliver it instead??" time 2000 
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H4_X $H4_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H4_X
    $HouseForSashaToDeliver_Y = $H4_Y
    $HouseForSashaToDeliver_Z = $H4_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H4
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker4   
    $LocToResetAfterSashaDeliverBox = 4
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~Why don't you send your mamma instead? Arrhhhh!" time 2000
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H5_X $H5_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H5_X
    $HouseForSashaToDeliver_Y = $H5_Y
    $HouseForSashaToDeliver_Z = $H5_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H5
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker5    
    $LocToResetAfterSashaDeliverBox = 5
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~Are you really going to do this with me? " time 2000
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H6_X $H6_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H6_X
    $HouseForSashaToDeliver_Y = $H6_Y
    $HouseForSashaToDeliver_Z = $H6_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H6
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker6    
    $LocToResetAfterSashaDeliverBox = 6
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~You mother ducker! I wasn't expecting it!" time 2000
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H7_X $H7_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H7_X
    $HouseForSashaToDeliver_Y = $H7_Y
    $HouseForSashaToDeliver_Z = $H7_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H7
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker7    
    $LocToResetAfterSashaDeliverBox = 7
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~I can't believe you had this audacity! Having this option doesn't mean you gotta choose it!" time 2000   
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H8_X $H8_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H8_X
    $HouseForSashaToDeliver_Y = $H8_Y
    $HouseForSashaToDeliver_Z = $H8_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H8
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker8    
    $LocToResetAfterSashaDeliverBox = 8
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~If i were your wife, i would have gone with anyone that would come to my door!" time 2000  
    wait 2000   
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H9_X $H1_9 radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H9_X
    $HouseForSashaToDeliver_Y = $H9_Y
    $HouseForSashaToDeliver_Z = $H9_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H9
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker9    
    $LocToResetAfterSashaDeliverBox = 9
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~w~Who raised you? Your dogs, isn't? How could you do this to me as a woman?" time 2000
    wait 2000
    jump @HousesCoordinates
end

if 
    00EC: actor $Actor1 sphere 0 near_point $H10_X $H10_Y radius 21@ 22@
then
    $HouseForSashaToDeliver_X = $H10_X
    $HouseForSashaToDeliver_Y = $H10_Y
    $HouseForSashaToDeliver_Z = $H10_Z
    gosub @CompareZHeightTruckXHouse
    if $SashaRefusedZHeight == 1
    then
        $MakeSashaDeliverBox1 = 0
        jump @HousesCoordinates
    end
    $Sasha_DeliverLOC_Sphere = $H10
    $Sasha_DeliverLOC_Marker = $HouseFrontMarker10    
    $LocToResetAfterSashaDeliverBox = 10
    $MakeSashaDeliverBox1 = 1    
    $FightWithSashaHusband = 1     
    
    0AD1: show_formatted_text_highpriority "~w~Don't you realize you're being very machist? My husband is not gonna like it!" time 2000     
    wait 2000              
    jump @HousesCoordinates
end
     
/// If there's no closest location to deliver:
0AD1: show_formatted_text_highpriority "~w~You really think i'm fucking stupid? I'm not walking that far away. Do it yourself!" time 2000 
wait 1500
$EnableSashaFollowSystem = 1
$MakeSashaDeliverBox1 = 0 

// FIX: If it falls through here, we MUST jump back to the main loop to prevent hitting random code/returns below!
jump @HousesCoordinates


//////////////////////////////////CLOSE SASHA DIALOG PANEL
:CloseSashaDialogMenuPanel 
wait 0
08DA: remove_panel $SashaDialogMENU   
$SashaDialogMENU_Open = 0
Player.CanMove($PLAYER_CHAR) = True
return
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////*******************************************


/////////////////------------------------------------------------------------------ MAKE SASHA DELIVER THE BOX
/////////////////////////////////////////////////////////////////////////////////////////////////////////
:MakeSashaDeliverBox1
wait 0 
Player.CanMove($PLAYER_CHAR) = false

gosub @CarMechanisms   
gosub @MissionFailedCheck1  
gosub @CJCarryBoxAnimCheck 

if
  00DB: not actor $Actor1 in_car $Truck 
  then   
    0687: clear_actor $Actor1 task
    wait 0
    0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
    wait 10
    $EnableSashaFollowSystem = 0
    $Actor1FollowPlayer = 0
    $Actor1InCarWithPlayer = 0
    $MakeSashaDeliverBox1 = 1
    0AD1: show_formatted_text_highpriority "~r~Wait for her to make the delivery." time 1500
    wait 200
    jump @PickUpBoxInTruck_And_Deliver1
else
   if
    00DB: actor $Actor1 in_car $Truck
then
    0687: clear_actor $Actor1 task
    wait 0
    0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
    wait 10
    $Actor1InCarWithPlayer = 0
    $MakeSashaDeliverBox1 = 1
    0633: AS_actor $Actor1 exit_car
    wait 10
    $EnableSashaFollowSystem = 0
    $Actor1FollowPlayer = 0
    0AD1: show_formatted_text_highpriority "~r~Wait for Sasha to make the delivery." time 1500
    jump @PickUpBoxInTruck_And_Deliver1
 end
end
   


//////////////////////////////////////
:PickUpBoxInTruck_And_Deliver1
wait 0 
gosub @CarMechanisms   
gosub @MissionFailedCheck1  
gosub @CJCarryBoxAnimCheck       
////////////////////////////-------------------------------
gosub @CheckActor1DistanceFromTruck ////////////////////////////////////////////////Check if car is not too far away from eliv location

0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0

// ========================================
// TIMER SYSTEM - Reissue task if stuck
// ========================================

// Start timer on first entry (only once)
if
    $SashaDeliverTimerStarted == 0
then
    $SashaDeliverTimerStart = timera
    $SashaDeliverTimerStarted = 1
end

// Check if 5 seconds passed without reaching destination
if
    timera > 2800
then
    0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
    05D3: AS_actor $Actor1 goto_point 6@ 7@ 8@ mode 4 time -1
    wait 0 // Let the engine register the walk task before applying animation
    timera = 0
end
///////////////////////////////----------------------------------------------------------------


////If Sasha reaches back of the truck
if
 00ED: actor $Actor1 sphere 0 near_point 6@ 7@ radius 1.1 1.1 on_foot 
 then
    08A6: set_car $Truck door $TrunkID rotation_to 1.0
    if 
        $LoadedBoxesIntoTruck > 0
    then
        04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 -4.5 0.0
        wait 0
        05C0: AS_actor $Actor1 look_at_car $Truck 400 ms
        wait 50
        0812: AS_actor $Actor1 perform_animation "liftup" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 650
        wait 350
        gosub @UpdateTruckVisualBoxes
        wait 0
        0107: $CurrentBox = create_object 1580 at 9@ 10@ 11@ 
        069B: attach_object $CurrentBox to_actor $Actor1 with_offset 0.0 0.60 0.30 rotation 0.0 0.0 0.0
        $LoadedBoxesIntoTruck -= 1
        gosub @UpdateTruckVisualBoxes
        wait 0
        jump @Actor1_GoDeliverBox_Prep
    else 
       0AD1: show_formatted_text_highpriority "~w~ Are you fucking kidding me? The truck is empty!!" time 3000
       wait 0
       jump @MISSIONCLEANUP   
        end
   end   

jf @PickUpBoxInTruck_And_Deliver1


/////////////////////////////////////////
:Actor1_GoDeliverBox_Prep
wait 0
Player.CanMove($PLAYER_CHAR) = true
gosub @CarMechanisms   
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu

gosub @CJCarryBoxAnimCheck 

/////////////////-------------------

08A6: set_car $Truck door $TrunkID rotation_to 0.0 
wait 50
// GIVE WALKING AND ANIMATION TASK EXACTLY ONCE
05D3: AS_actor $Actor1 goto_point $HouseForSashaToDeliver_X $HouseForSashaToDeliver_Y $HouseForSashaToDeliver_Z mode 4 time -1
0605: actor $Actor1 apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1

$StopCloserWarn = 0  /// Reset var to warn player about distance
$SashaDeliverTimerStarted = 0 /// RESET TIMER to tell $Actor1 to GOTO POINT

 
:Actor1_GoDeliverBox
wait 0
gosub @CarMechanisms   
gosub @MissionFailedCheck1  

gosub @CJCarryBoxAnimCheck 
// ========================================
// TIMER SYSTEM - Reissue task if stuck
// ========================================

// Start timer on first entry (only once)
if
    $SashaDeliverTimerStarted == 0
then
    $SashaDeliverTimerStart = timera
    $SashaDeliverTimerStarted = 1
end

// Check if 5 seconds passed without reaching destination
if
    timera > 2500
then
    05D3: AS_actor $Actor1 goto_point $HouseForSashaToDeliver_X $HouseForSashaToDeliver_Y $HouseForSashaToDeliver_Z mode 4 time -1
    wait 0 // Let the engine register the walk task before applying animation
    0605: actor $Actor1 apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
    timera = 0
end
    
               
////////////////////////////////////////////////////////////// DELIVER BOX PART
if
 00EC: actor $Actor1 sphere 0 near_point $HouseForSashaToDeliver_X $HouseForSashaToDeliver_Y radius 2.5 2.5   
then
   04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.5 -1.0
   02CE: 11@ = ground_z_at 9@ 10@ 11@
   0605: actor $Actor1 apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
   wait 10
   0812: AS_actor $Actor1 perform_animation "putdwn" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 500
   wait 500
   0682: detach_object $CurrentBox 9@ 10@ 11@ collision_detection 1
   0812: AS_actor $Actor1 perform_animation "putdwn" IFP "CARRY" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time 1
   01BC: put_object $CurrentBox at 9@ 10@ 11@
   gosub @CheckWichBoxWasDelivered////////--------------------------------------------
   $BoxesDelivered += 1 
   gosub @SashaSaveDeliveredDroppedBox  
   03BD: destroy_sphere $Sasha_DeliverLOC_Sphere 
   0164: remove_marker $Sasha_DeliverLOC_Marker
   0AD1: show_formatted_text_highpriority "~w~ Wait for me, you bastard; if you want to get your money, of course!" time 2000
   wait 100
   0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0
   0687: clear_actor $Actor1 task
   wait 0
   05D3: AS_actor $Actor1 goto_point 6@ 7@ 8@ mode 4 time -1
   jump @Actor1_GoBackTruckAsPassenger_OrFollowPlayer
end	

jf @Actor1_GoDeliverBox


////////////////////////////////////////////////////////////
:Actor1_GoBackTruckAsPassenger_OrFollowPlayer
wait 0 
gosub @CarMechanisms   
gosub @MissionFailedCheck1  
gosub @OpenBackOfTheVanMenu

gosub @CJCarryBoxAnimCheck  

// Tell Sasha to follow again
$Actor1FollowPlayer = 1
$Actor1InCarWithPlayer = 0
$MakeSashaDeliverBox1 = 0
$EnableSashaFollowSystem = 1

///////////////////////////////////////////
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0
0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 -3.5 0.0

if and
  $ChosenDeliveryQTY > $BoxesDelivered
  00F2: actor $Actor1 near_actor $PLAYER_ACTOR radius 50.0 50.0 sphere 0
then
    0AD1: show_formatted_text_highpriority "~w~Let's move to the next location if you still want your money, of course!!" time 1500
    $SashaDeliveredTheBox = 1
    $Actor1FollowPlayer = 1
    wait 1500
    jump @StartMission3     
else
  if and
    $ChosenDeliveryQTY == $BoxesDelivered
   then
    if or
    00F3: actor $Actor1 near_actor $PLAYER_ACTOR radius 50.0 50.0 sphere 0 on_foot 
    00F4: actor $Actor1 near_actor $PLAYER_ACTOR radius 50.0 50.0 sphere 0 in_car
    then   
      0AD1: show_formatted_text_highpriority "~w~I think we're done here. Take me back to the store." time 1500  
      $SashaDeliveredTheBox = 1
      wait 2500
      jump @TakeSashaBack
     end
   end
end   

:TakeSashaBack///////////////////////////////////////////////////
wait 0 
gosub @CarMechanisms   
gosub @MissionFailedCheck1  

gosub @CJCarryBoxAnimCheck    
//////////////////////////////////////////////////// CHECK CARRYING BOX ANIM

///////////////////////////////////// CREATE MARKER TO DROP SASHA OFF IN FRONT OF THE STORE
if 
 $SashaDeliveredTheBox == 1
 then
   03BC: $FinishDeliveryWithSasha_Sphere = create_sphere_at 2464.8955 -1737.5326 13.5469 radius 3.0  
   018A: $FinishDeliveryWithSashaSphere_Marker = create_checkpoint_at 2464.8955 -1737.5326 13.5469 
   $Actor1FollowPlayer = 1
   $EnableSashaFollowSystem = 1
   0AD1: show_formatted_text_highpriority "~R~Drop Sasha off at the store." time 1500 
   wait 400
   jump @TakeSashaBack2////////////>>>>>>
end

////////////////////////////////////////////////////----------------------------------------
:TakeSashaBack2
wait 0
Player.CanMove($PLAYER_CHAR) = true

gosub @CarMechanisms   
gosub @MissionFailedCheck1  
gosub @CJCarryBoxAnimCheck 


//////////////////////////////////////////////-------------------- WHEN PLAYER REACHES SPHERE TO DROP SASHA OFF 
if and
    00EC: actor $PLAYER_ACTOR sphere 0 near_point 2464.8955 -1737.5326 radius 3.0 3.0
    $ONMISSION == 1
    $SashaDeliveredTheBox == 1
    $FightWithSashaHusband == 0 
 then
    $SashaDeliveredTheBox = 0
    $SashaDroppedOff = 1
    $Actor1FollowPlayer = 0
    $EnableSashaFollowSystem = 0
    03BD: destroy_sphere $FinishDeliveryWithSasha_Sphere
    0164: disable_marker $FinishDeliveryWithSashaSphere_Marker
    wait 0
    Player.CanMove($PLAYER_CHAR) = False
    015F: set_camera_position 2489.9565 -1729.2473 18.3828 rotation 0.0 0.0 205.2478
    0160: set_camera_point_at 2466.0525 -1741.5500 13.4030 switchstyle 2
    wait 1000
      if 00DB: actor $Actor1 in_car $Truck
        then
         0633: AS_actor $Actor1 exit_car
         wait 1500
    end
         
    jump @HousesCoordinates     
end
///////////////////////////////////////////////////////////////-------------------------


//////////////////////////////////////////////-------------------- WHEN PLAYER REACHES SPHERE TO DROP SASHA OFF AND FIGHTS SASHA'S HUSBAND:
if and
    00EC: actor $PLAYER_ACTOR sphere 0 near_point 2464.8955 -1737.5326 radius 3.0 3.0
    $ONMISSION == 1
    $SashaDeliveredTheBox == 1
    $FightWithSashaHusband == 1 
 then
    $SashaDeliveredTheBox = 0
    $SashaDroppedOff = 1
    $Actor1FollowPlayer = 0
    $EnableSashaFollowSystem = 0
    Player.CanMove($PLAYER_CHAR) = False
    015F: set_camera_position 2452.7339 -1726.1202 13.6548 rotation 0.0 0.0 205.2478
    0160: set_camera_point_at 2466.0525 -1741.5500 13.4030 switchstyle 2
    wait 500
      if 00DB: actor $Actor1 in_car $Truck
    then
        0633: AS_actor $Actor1 exit_car
        wait 1500
    end
       
     wait 1000   
    jump @FightSashaHusband     
end
///////////////////////////////////////////////////////////////-------------------------

/////////----------------------
if
     $SashaDeliveredTheBox == 1
then
    $SashaDeliverTimerStart = timera
    $SashaDeliverTimerStarted = 1
end

// Check if 5 seconds passed without reaching destination
if
    timera > 5000
then
    timera = 0
    gosub @Actor1FollowSystem
end    
//////////////////---------------------


jump @TakeSashaBack2///////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////



////////////----------------------------------
:FightSashaHusband 
wait 0 
gosub @MissionFailedCheck1  
gosub @CJCarryBoxAnimCheck 

038B: load_requested_models

:WAIT_MODEL
wait 0
if
   0248: model #WMYGOL2 available
else_jump @WAIT_MODEL

009A: $SashaHusband = create_actor_pedtype 4 model #WMYGOL2 at 2477.4167 -1749.4296 13.5469 
017B: set_actor $SashaHusband weapon 5 ammo 99999      // Baseball Bat
01B2: give_actor $SashaHusband weapon 5 ammo 99999


//======================================================
// Walk to waypoint 1
//======================================================

05D3: AS_actor $SashaHusband goto_point 2477.8599 -1740.2943 13.5469 mode 6 time 1500

:WAIT_WP3
wait 0
if
00EC: actor $SashaHusband sphere 0 near_point 2477.8599 -1740.2943 radius 2.0 2.0
else_jump @WAIT_WP3

//======================================================
// Walk to waypoint 2
//======================================================

05D3: AS_actor $SashaHusband goto_point 2471.3752 -1738.9333 13.5469 mode 6 time -1

:WAIT_WP4
wait 0
if
00EC: actor $SashaHusband sphere 0 near_point 2471.3752 -1738.9333 radius 2.5 2.5
else_jump @WAIT_WP4

//======================================================
// Face the truck
05E2: AS_actor $SashaHusband turn_to_face_vehicle $Truck
wait 800
01B4: set_player $PLAYER_CHAR can_move 0
// Talking animation
0812: AS_actor $SashaHusband perform_animation "IDLE_CHAT" IFP "PED" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1
0AD1: show_formatted_text_highpriority "~w~Hey, pal. I was listening to everything you said to my wife. Now i'll teach your ass, how hard it can get!!" time 4000
wait 3000
// Attack the player
05E2: AS_actor $SashaHusband kill_actor $PLAYER_ACTOR
07FE: set_actor $SashaHusband fighting_style_to 17 moves 6 /// Muay thay

0223: set_actor $SashaHusband health_to 500
02E2: set_actor $SashaHusband weapon_accuracy_to 100
0249: release_model #WMYGOL2

02EB: restore_camera_with_jumpcut
0826: enable_hud 1
0581: enable_radar 1
01B4: set_player $PLAYER_CHAR can_move 1

0187: 29@ = create_marker_above_actor $SashaHusband
0AD1: show_formatted_text_highpriority "~R~Fight with Sasha's husband!!" time 2500
Player.CanMove($PLAYER_CHAR) = true

  if 00DB: actor $PLAYER_ACTOR in_car $Truck
    then
        0633: AS_actor $PLAYER_ACTOR exit_car  
        wait 1500   
    end

:SashasHusbandDead
wait 0 
gosub @CJCarryBoxAnimCheck 
gosub @MissionFailedCheck1  
if
 0118: actor $SashaHusband dead
 then
   0164: disable_marker 29@
   wait 50
   jump @Finish
end

jump @SashasHusbandDead

//////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////--------------------------------------------------
:CompareZHeightTruckXHouse
wait 0
gosub @MissionFailedCheck1  
gosub @CarMechanisms   
gosub @CJCarryBoxAnimCheck 

0407: store_coords_to 6@ 7@ 8@ from_car $Truck with_offset 0.0 0.0 0.0

// Compute height difference correctly without corrupting the House Z variable!
4@ = $HouseForSashaToDeliver_Z
4@ -= 8@
 
if
 4@ > 2.5
then
    0AD1: show_formatted_text_highpriority "~r~No way i'm going up there. Go yourself!" time 3000  
    $SashaRefusedZHeight = 1
    wait 1500
    return // FIX: Must use return instead of jump!
end

if
 4@ < -2.5
then
    0AD1: show_formatted_text_highpriority "~r~Too steep; you go! Who's paying you? Remember?" time 3000
    $SashaRefusedZHeight = 1
    wait 1500
    return // FIX: Must use return instead of jump!
end

$SashaRefusedZHeight = 0
return
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


:CJCarryBoxAnimCheck
wait 0 
 if  
   $AlreadyPlaying_CarryingBox == 1
 then
   return
 end  

if and
  0AB0: not key_pressed 87 
  0AB0: not key_pressed 83
  0AB0: not key_pressed 65 
  0AB0: not key_pressed 68
  0AB0: not key_pressed 37 
  0AB0: not key_pressed 38
  0AB0: not key_pressed 39 
  0AB0: not key_pressed 40   
  then
    if  
     $PlayCarryingBoxAnim == 1
 then
        // loop 1: Keeps arms up
        // lockX/Y 0: Allows player to move position
        // lockF 0: CRUCIAL - Allows player to turn/rotate
        // time -1: Plays forever until cleared
         $AlreadyPlaying_CarryingBox = 1
        0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 1.0 loop 0 lockX 0 lockY 0 lockF 0 time 50
        wait 100
        return
    end
else
    // If we stopped carrying the box, but the anim is still playing:
    if
        0611: actor $PLAYER_ACTOR performing_animation "crry_prtial"
    then
        // We stop the animation by playing it for 1ms
         $AlreadyPlaying_CarryingBox = 0
        0605: actor $PLAYER_ACTOR apply_animation "crry_prtial" IFP "CARRY" 4.0 loop 0 lockX 0 lockY 0 lockF 0 time 1
        return
       end
    end
    
return
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
:CheckActor1DistanceFromTruck
wait 0 
gosub @MissionFailedCheck1  
0407: store_coords_to $TD1 $TD2 $TD3 from_car $Truck with_offset 0.0 0.0 0.0
04C4: store_coords_to 9@ 10@ 11@ from_actor $Actor1 with_offset 0.0 0.0 0.0

050A: 2@ = distance_between_XYZ $TD1 $TD2 $TD3 and_XYZ 9@ 10@ 11@
 
// FIX 1: You MUST use 30.0 (Float), not 30 (Integer)
if
 2@ > 30.0
then
   0AD1: show_formatted_text_highpriority "~r~Look, i'm not playing! Come back with this damm truck right here!" time 1500
end

// FIX 2: Removed the "else/jump" trap. Now it simply returns back to the main loop safely!
return
////////////////////////////////////////////////////////////////////////////



:CheckWichBoxWasDelivered//////////////////////////////////////////
wait 0

if
    $LocToResetAfterSashaDeliverBox == 0
then
    $Delivered0 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 1
then
    $Delivered1 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 2
then
    $Delivered2 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 3
then
    $Delivered3 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 4
then
    $Delivered4 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 5
then
    $Delivered5 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 6
then
    $Delivered6 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 7
then
    $Delivered7 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 8
then
    $Delivered8 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 9
then
    $Delivered9 = 1
end

if
    $LocToResetAfterSashaDeliverBox == 10
then
    $Delivered10 = 1
end

return
////////////////////////////////////////////////////////////////////////////////////////





///////////////////////////////////////////////////////////////
:UpdateTruckVisualBoxes
wait 0
// --- BOX 1 ---
if $LoadedBoxesIntoTruck >= 1
then
    if $TruckBox0 == -1
    then 
        0107: $TruckBox0 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox0 to_car $Truck with_offset -0.3 -1.0 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox0 > -1
    then
        0108: destroy_object $TruckBox0
        $TruckBox0 = -1
    end
end

// --- BOX 2 ---
if $LoadedBoxesIntoTruck >= 2
then
    if $TruckBox1 == -1
    then 
        0107: $TruckBox1 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox1 to_car $Truck with_offset 0.3 -1.0 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox1 > -1
    then
        0108: destroy_object $TruckBox1
        $TruckBox1 = -1
    end
end

// --- BOX 3 ---
if $LoadedBoxesIntoTruck >= 3
then
    if $TruckBox2 == -1
    then 
        0107: $TruckBox2 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox2 to_car $Truck with_offset -0.3 -1.5 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox2 > -1
    then
        0108: destroy_object $TruckBox2
        $TruckBox2 = -1
    end
end

// --- BOX 4 ---
if $LoadedBoxesIntoTruck >= 4
then
    if $TruckBox3 == -1
    then 
        0107: $TruckBox3 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox3 to_car $Truck with_offset 0.3 -1.5 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox3 > -1
    then
        0108: destroy_object $TruckBox3
        $TruckBox3 = -1
    end
end

// --- BOX 5 ---
if $LoadedBoxesIntoTruck >= 5
then
    if $TruckBox4 == -1
    then 
        0107: $TruckBox4 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox4 to_car $Truck with_offset -0.3 -2.0 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox4 > -1
    then
        0108: destroy_object $TruckBox4
        $TruckBox4 = -1
    end
end

// --- BOX 6 ---
if $LoadedBoxesIntoTruck >= 6
then
    if $TruckBox5 == -1
    then 
        0107: $TruckBox5 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox5 to_car $Truck with_offset 0.3 -2.0 0.1 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox5 > -1
    then
        0108: destroy_object $TruckBox5
        $TruckBox5 = -1
    end
end

// --- BOX 7 ---
if $LoadedBoxesIntoTruck >= 7
then
    if $TruckBox6 == -1
    then 
        0107: $TruckBox6 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox6 to_car $Truck with_offset -0.3 -1.0 0.45 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox6 > -1
    then
        0108: destroy_object $TruckBox6
        $TruckBox6 = -1
    end
end

// --- BOX 8 ---
if $LoadedBoxesIntoTruck >= 8
then
    if $TruckBox7 == -1
    then 
        0107: $TruckBox7 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox7 to_car $Truck with_offset 0.3 -1.0 0.45 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox7 > -1
    then
        0108: destroy_object $TruckBox7
        $TruckBox7 = -1
    end
end

// --- BOX 9 ---
if $LoadedBoxesIntoTruck >= 9
then
    if $TruckBox8 == -1
    then 
        0107: $TruckBox8 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox8 to_car $Truck with_offset -0.3 -1.5 0.45 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox8 > -1
    then
        0108: destroy_object $TruckBox8
        $TruckBox8 = -1
    end
end

// --- BOX 10 ---
if $LoadedBoxesIntoTruck >= 10
then
    if $TruckBox9 == -1
    then 
        0107: $TruckBox9 = create_object 1580 at 0.0 0.0 0.0
        0681: attach_object $TruckBox9 to_car $Truck with_offset 0.3 -1.5 0.45 rotation 0.0 0.0 0.0
    end
else
    if $TruckBox9 > -1
    then
        0108: destroy_object $TruckBox9
        $TruckBox9 = -1
    end
end
return


//////////////////////////////////////////////////////////////////////////////////////////////////////////////



























0A93: terminate_this_custom_script